在word中怎么用C#代码新建一个不可编辑区域(不能复制,修改,剪切)
word能不能像其他控件一样绑定数据库的数据源
高手指教,这是我发布的第二贴了
最好是有C#代码
word能不能像其他控件一样绑定数据库的数据源
高手指教,这是我发布的第二贴了
最好是有C#代码
解决方案 »
- C#2008 代码 控制USB摄像头 ,不能显示图像?
- Microsoft.Office.Interop.Excel 回归过程的录制宏问题
- dtatgridview刷新后滚动条复位,怎样解决?
- 请大大们指教!
- 如何在服务器端获得浏览者的计算机名称?
- ToolBarButton里的图像为什么显示不出来
- 一个水晶报表出现登录框的老问题。100分,不够再开贴
- 请问如何在listview的动态生成的列表显示图片啊,我用的detail视图,并设置了smallIcon为Imagelist中的icon图片的索引,但是运行后,列表
- 正则表达式问题
- 100分,特别的上传问题,请帮忙,(非常有意思)我是jsp完成不了才转向求一个aspx页面,主要内容集中在上传和图片缩放
- c#实现p2p的流媒体视频系统,求方法(用tcp)或者源码
- 这个语句的意思
给你推荐一下SOA中间件,我公司以前开发在线编辑word用的就是这个,但是是收费的。
并且不是B/s的
使用方法: object oMissing = System.Reflection.Missing.Value; Word.Application oWord =new Word.Application(); oWord.Visible = false;//设置Word应用程序为不可见//新建一个Word文档
Word.Document oDoc=oWord.Documents.Add(ref oMissing,ref oMissing ,ref oMissing,ref oMissing); //文档内容的复制与粘贴 oDoc.Content.Copy();
oDoc.Content.Paste()//文档的另存为oDoc.SaveAs(ref fileName,ref saveFormat,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);//其他设置 oDoc.PageSetup.PaperSize=Word.WdPaperSize.wdPaperA3;//页面设置
oDoc.PageSetup.Orientation=Word.WdOrientation.wdOrientLandscape;//横板还是竖板
oDoc.PageSetup.TextColumns.SetCount(2);//分栏//关闭Word oWord.Application.Quit(ref b,ref oMissing,ref oMissing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);通过oDoc对象对Word文档进行操作(word能做的它都能做)进行操作里面有很多函数,有兴趣的自己研究将word文档里面的文字读入到数据库中,用.net实现:试试文件操作的类:
public class FileControl
{
public FileControl()
{ }
/**/
///
/// 在根目录下创建文件夹
///
/// 要创建的文件路径
public void CreateFolder(string FolderPathName)
{
if (FolderPathName.Trim().Length > 0)
{
try
{
string CreatePath = System.Web.HttpContext.Current.Server.MapPath ("../../../Images/" + FolderPathName).ToString();
if (!Directory.Exists(CreatePath))
{
Directory.CreateDirectory(CreatePath);
}
}
catch(Exception ex)
{
throw;
}
}
} /**/
///
/// 删除一个文件夹下面的字文件夹和文件
///
///
public void DeleteChildFolder(string FolderPathName)
{
if (FolderPathName.Trim().Length > 0)
{
try
{
string CreatePath = System.Web.HttpContext.Current.Server.MapPath (FolderPathName).ToString();
if (Directory.Exists(CreatePath))
{
Directory.Delete(CreatePath, true);
}
}
catch(Exception ex)
{
throw;
}
}
} /**/
///
/// 删除一个文件
///
///
public void DeleteFile(string FilePathName)
{
try
{
FileInfo DeleFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath (FilePathName).ToString());
DeleFile.Delete();
}
catch(Exception ex)
{
throw;
}
}
public void CreateFile(string FilePathName)
{
try
{
//创建文件夹
//string[] strPath= FilePathName.Split('/');
//CreateFolder(FilePathName.Replace("/" + strPath[strPath.Length-1].ToString(),"")); //创建文件夹
FileInfo CreateFile =new FileInfo(FilePathName); //创建文件
if(!CreateFile.Exists)
{
FileStream FS=CreateFile.Create();
FS.Close();
}
}
catch(Exception ex)
{
throw;
}
}
/**/
///
/// 删除整个文件夹及其字文件夹和文件
///
///
public void DeleParentFolder(string FolderPathName)
{
try
{
DirectoryInfo DelFolder = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath (FolderPathName).ToString());
if (DelFolder.Exists)
{
DelFolder.Delete();
}
}
catch
{
}
}
/**/
///
/// 在文件里追加内容
///
///
public void ReWriteReadinnerText(string FilePathName, string WriteWord)
{
try
{
//建立文件夹和文件
//CreateFolder(FilePathName);
//CreateFile(FilePathName);
//得到原来文件的内容
FileStream FileRead = new FileStream(FilePathName, FileMode.Append,FileAccess.Write);
//StreamReader FileReadWord = new StreamReader(FileRead, System.Text.Encoding.Default);
//string OldString = FileReadWord.ReadToEnd().ToString();
//OldString = OldString + WriteWord;
//把新的内容重新写入
StreamWriter FileWrite = new StreamWriter(FileRead, System.Text.Encoding.Default);
FileWrite.Write(WriteWord);
//关闭
FileWrite.Close();
//FileReadWord.Close();
FileRead.Close();
}
catch(Exception ex)
{
// throw;
}
} /**/
///
/// 在文件里追加内容
///
///
public string ReaderFileData(string FilePathName)
{
try
{ FileStream FileRead = new FileStream(System.Web.HttpContext.Current.Server.MapPath (FilePathName).ToString(), FileMode.Open, FileAccess.Read);
StreamReader FileReadWord = new StreamReader(FileRead, System.Text.Encoding.Default);
string TxtString = FileReadWord.ReadToEnd().ToString();
//关闭
FileReadWord.Close();
FileRead.Close();
return TxtString;
}
catch
{
throw;
}
}
/**/
///
/// 读取文件夹的文件
///
///
///
public DirectoryInfo checkValidSessionPath(string FilePathName)
{
try
{
DirectoryInfo MainDir = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath (FilePathName));
return MainDir; }
catch
{
throw;
}
}
}
document.Sections[i].ProtectedForForms = false;//不需要保护的节
document.Sections[i].ProtectedForForms = true;//要保护的节 document.Protect(WdProtectionType.wdAllowOnlyFormFields, ref noReset, ref password, ref useIRM, ref enforceStyleLock);