请教高手能否提供一些经典的WORD建立,读取和保存 添加一个对 Microsoft Word 对象库和 Microsoft Visual C# for Applications 扩展性库的引用。为此,请按照下列步骤操作: 在项目菜单上,单击添加引用。在 COM 选项卡上,找到 Microsoft Word 对象库并单击选择。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private Word.Application thisApplication = null;private Word.Document thisDocument = null;Word.Application appWord = new Word.Application();Word.Window wnd = ThisApplication.ActiveWindow.NewWindow(); // Tile the two windows. Object value = Word.WdArrangeStyle.wdTiled; ThisApplication.Windows.Arrange(ref value); 参考一下连接:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/OffCSharp.asphttp://support.microsoft.com/?kbid=303872 public CreateWordFile(string fileName,string redFile,string titleText,string docType,string dwmc,string serialNo) { //docType=1时表示行政公文,=2时表示党的公文,=3表示普通公文 try { Word.Application app = new Word.Application(); app.Visible=false; object optional=Missing.Value; object visible = true; object template = Application.StartupPath+"\\2060\\oa.dot"; object True=true; object False=false; object Zero=0; object FileName=fileName; object RedFile=redFile; int picHeight=133; float linePosition=picHeight+120F; Word._Document doc = app.Documents.Add(ref template,ref False,ref Zero,ref visible); //设置页面(从模板中生成) //doc.Words.Application.ActiveDocument.PageSetup.TopMargin= doc.Words.Application.CentimetersToPoints(3.8F); //doc.Words.Application.ActiveDocument.PageSetup.BottomMargin = doc.Words.Application.CentimetersToPoints(3.5F); //doc.Words.Application.ActiveDocument.PageSetup.LeftMargin=doc.Words.Application.CentimetersToPoints(2.8F); //doc.Words.Application.ActiveDocument.PageSetup.RightMargin=doc.Words.Application.CentimetersToPoints(2.6F); //doc.Words.Application.ActiveDocument.PageSetup.FooterDistance=doc.Words.Application.CentimetersToPoints(2.8F); //生成内容 Word.Selection selection=doc.Words.Application.ActiveDocument.ActiveWindow.ActivePane.Selection; selection.Paragraphs.Alignment=Word.WdParagraphAlignment.wdAlignParagraphCenter; if(docType!="3") { selection.InlineShapes.AddPicture(redFile,ref False,ref True,ref optional); selection.TypeParagraph(); selection.Font.Name = "仿宋_GB2312"; selection.Font.Size = 16; selection.TypeText(serialNo); selection.TypeParagraph(); selection.TypeParagraph(); } selection.TypeParagraph(); selection.Font.Name = "黑体"; selection.Font.Size = 22; selection.TypeText(titleText); selection.TypeParagraph(); selection.TypeParagraph(); selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft; selection.Font.Size = 16; selection.Font.Name = "仿宋_GB2312"; selection.ParagraphFormat.LineSpacingRule=Word.WdLineSpacing.wdLineSpaceExactly; selection.ParagraphFormat.LineSpacing=30; selection.TypeText("此处更改为发文对象:"); selection.TypeParagraph(); selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(1.3F); selection.TypeText("此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容"); selection.TypeParagraph(); selection.TypeParagraph(); selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(9F); selection.TypeText(dwmc); selection.TypeParagraph(); selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(10F); selection.TypeText("此处更改为发文时间"); if(docType!="3") { float left=74.0F; float right=529.0F; int color=255; if(docType=="1") { doc.Words.Application.ActiveDocument.Shapes.AddLine(left,linePosition,right,linePosition,ref optional).Select(ref False); selection.ShapeRange.Line.ForeColor.RGB = color; selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue; selection.ShapeRange.Line.Weight = 1.5F; selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; } if(docType=="2") { float right1=left+220F; float left1=right1+20F; doc.Words.Application.ActiveDocument.Shapes.AddLine(left,linePosition,right1,linePosition,ref optional).Select(ref False); selection.ShapeRange.Line.ForeColor.RGB = color; selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue; selection.ShapeRange.Line.Weight = 1.5F; selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; doc.Words.Application.ActiveDocument.Shapes.AddShape((int)Office.MsoAutoShapeType.msoShape5pointStar,right1+2,linePosition-7.53F,15.75F,15.75F,ref optional).Select(ref False); selection.ShapeRange.Line.ForeColor.RGB = color; selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue; selection.ShapeRange.Line.Weight = 1F; selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; selection.ShapeRange.Fill.ForeColor.RGB=color; selection.ShapeRange.Fill.Solid(); doc.Words.Application.ActiveDocument.Shapes.AddLine(left1,linePosition,right,linePosition,ref optional).Select(ref False); selection.ShapeRange.Line.ForeColor.RGB = color; selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue; selection.ShapeRange.Line.Weight = 1.5F; selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; } selection.Collapse(ref optional); //selection.Sections.Item(1).Footers.Item(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.NumberStyle=Word.WdPageNumberStyle.wdPageNumberStyleArabic; //object align=Word.WdPageNumberAlignment.wdAlignPageNumberCenter; //selection.Sections.Item(1).Footers.Item(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.Add(ref align,ref True); } //doc.Words.First.InsertBefore("This document is no longer empty!"); object file = fileName; doc.SaveAs(ref file, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional); object saveChanges = false; app.Quit(ref saveChanges, ref optional, ref optional); } catch(System.Exception ex) { MessageBox.Show(ex.Message); } } WebOffice2004是一个基于Web的Web Office ActiveX控件,把word和excel等office软件集成在IE浏览器中,实现Web办公自动化。提供的功能: 1,新建word,excel文档 2,打开word,excel文档 3,修改word,excel文档 4,保存Word,excel文档 5,对工具条的隐藏和显示另外,在本版中WebOffice2004只负责编辑Word或者Excel的工作,不负责向服务器数据库传输数据和从服务器数据库下载数据,为此,我们自行研发了一套基于纯Java的客户端上传控件和下载控件。客户端上传控件:主要用来向服务器端传输数据,支持标准的 RFC 1867 文件传输协议。服务器端只需使用向aspupload等上传控件接收数据即可。 原有的控件所采取的机制是客户端直接连接服务器的数据库,这样做的缺点是如果服务器上存在防火墙,将不能连接数据库。这样,此控件的实用性将大大降低,而我们此次升级主要是为了解决此问题。上传控件实现了从客户端上传一个或者多个文件的问题,即可以通过在空件中隐含的上传数据,而传统的使用 <input type="file" name="file1">这种客户端上传技术由于受到安全方面的限制,程序不能对file控件赋值,而我们的 上传控件解决了此难题,而且,我们的上传控件兼容所有的服务器端上传控件。 下载控件:此控件使从服务器下载数据到客户端的过程中速度明显的提高了,而且,有进度条显示,让客户直到数据下载的进程。使用上面的两个控件后,我们可以很容易的把客户端编辑的word文档很容易的保存到服务器端的数据库中。本产品支持所有版本的word,简单易用并附有完整的例子,很方便,如果有意,请发邮件到[email protected]索取试用版和完整的asp例子本产品每套只需500元。注意:试用版只能在本地机上免费使用2个月,功能跟正式版一样。email;[email protected]联系人:叶先生 TO: Frankeny(浩海冰蓝) Microsoft Visual C# for Applications 这个引用我怎么找不到 求助求助了,请问Web服务要怎么写? 请问苏宁易购那个“全部商品分类”的数据是怎么来的? spread的问题 这段脚本为何提示出错? (急)checkbox取不到值 问道js的问题....在线等! 关于session的一个奇怪的头疼问题~倾家荡产求大侠指点! c#中如何把excel文件打开,把数据读入数据库?高分求解 求图片库管理软件 easyui datagrid控件,直接输入页码数字怎么没有分页处理。如图。 petshop3.0问题,关于调用数据库PetShop.SQLServerDAL.dll文件 正在学习asp.net,程序中的一句不明白,想请教大家
private Word.Document thisDocument = null;
Word.Application appWord = new Word.Application();
Word.Window wnd = ThisApplication.ActiveWindow.NewWindow(); // Tile the two windows.
Object value = Word.WdArrangeStyle.wdTiled;
ThisApplication.Windows.Arrange(ref value);
{
//docType=1时表示行政公文,=2时表示党的公文,=3表示普通公文
try
{
Word.Application app = new Word.Application();
app.Visible=false;
object optional=Missing.Value;
object visible = true;
object template = Application.StartupPath+"\\2060\\oa.dot";
object True=true;
object False=false;
object Zero=0;
object FileName=fileName;
object RedFile=redFile;
int picHeight=133;
float linePosition=picHeight+120F;
Word._Document doc = app.Documents.Add(ref template,ref False,ref Zero,ref visible);
//设置页面(从模板中生成)
//doc.Words.Application.ActiveDocument.PageSetup.TopMargin= doc.Words.Application.CentimetersToPoints(3.8F);
//doc.Words.Application.ActiveDocument.PageSetup.BottomMargin = doc.Words.Application.CentimetersToPoints(3.5F);
//doc.Words.Application.ActiveDocument.PageSetup.LeftMargin=doc.Words.Application.CentimetersToPoints(2.8F);
//doc.Words.Application.ActiveDocument.PageSetup.RightMargin=doc.Words.Application.CentimetersToPoints(2.6F);
//doc.Words.Application.ActiveDocument.PageSetup.FooterDistance=doc.Words.Application.CentimetersToPoints(2.8F);
//生成内容
Word.Selection selection=doc.Words.Application.ActiveDocument.ActiveWindow.ActivePane.Selection;
selection.Paragraphs.Alignment=Word.WdParagraphAlignment.wdAlignParagraphCenter;
if(docType!="3")
{
selection.InlineShapes.AddPicture(redFile,ref False,ref True,ref optional);
selection.TypeParagraph();
selection.Font.Name = "仿宋_GB2312";
selection.Font.Size = 16;
selection.TypeText(serialNo);
selection.TypeParagraph();
selection.TypeParagraph();
}
selection.TypeParagraph();
selection.Font.Name = "黑体";
selection.Font.Size = 22;
selection.TypeText(titleText);
selection.TypeParagraph();
selection.TypeParagraph();
selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
selection.Font.Size = 16;
selection.Font.Name = "仿宋_GB2312";
selection.ParagraphFormat.LineSpacingRule=Word.WdLineSpacing.wdLineSpaceExactly;
selection.ParagraphFormat.LineSpacing=30;
selection.TypeText("此处更改为发文对象:");
selection.TypeParagraph();
selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(1.3F);
selection.TypeText("此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容此处更改为发文内容");
selection.TypeParagraph();
selection.TypeParagraph();
selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(9F);
selection.TypeText(dwmc);
selection.TypeParagraph();
selection.ParagraphFormat.FirstLineIndent=doc.Words.Application.CentimetersToPoints(10F);
selection.TypeText("此处更改为发文时间");
if(docType!="3")
{
float left=74.0F;
float right=529.0F;
int color=255;
if(docType=="1")
{
doc.Words.Application.ActiveDocument.Shapes.AddLine(left,linePosition,right,linePosition,ref optional).Select(ref False);
selection.ShapeRange.Line.ForeColor.RGB = color;
selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue;
selection.ShapeRange.Line.Weight = 1.5F;
selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle;
}
if(docType=="2")
{
float right1=left+220F;
float left1=right1+20F;
doc.Words.Application.ActiveDocument.Shapes.AddLine(left,linePosition,right1,linePosition,ref optional).Select(ref False);
selection.ShapeRange.Line.ForeColor.RGB = color;
selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue;
selection.ShapeRange.Line.Weight = 1.5F;
selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; doc.Words.Application.ActiveDocument.Shapes.AddShape((int)Office.MsoAutoShapeType.msoShape5pointStar,right1+2,linePosition-7.53F,15.75F,15.75F,ref optional).Select(ref False);
selection.ShapeRange.Line.ForeColor.RGB = color;
selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue;
selection.ShapeRange.Line.Weight = 1F;
selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle;
selection.ShapeRange.Fill.ForeColor.RGB=color;
selection.ShapeRange.Fill.Solid(); doc.Words.Application.ActiveDocument.Shapes.AddLine(left1,linePosition,right,linePosition,ref optional).Select(ref False);
selection.ShapeRange.Line.ForeColor.RGB = color;
selection.ShapeRange.Line.Visible = Office.MsoTriState.msoTrue;
selection.ShapeRange.Line.Weight = 1.5F;
selection.ShapeRange.Line.Style = Office.MsoLineStyle.msoLineSingle; }
selection.Collapse(ref optional);
//selection.Sections.Item(1).Footers.Item(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.NumberStyle=Word.WdPageNumberStyle.wdPageNumberStyleArabic;
//object align=Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
//selection.Sections.Item(1).Footers.Item(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.Add(ref align,ref True); }
//doc.Words.First.InsertBefore("This document is no longer empty!"); object file = fileName;
doc.SaveAs(ref file,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional);
object saveChanges = false;
app.Quit(ref saveChanges, ref optional, ref optional);
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
提供的功能:
1,新建word,excel文档
2,打开word,excel文档
3,修改word,excel文档
4,保存Word,excel文档
5,对工具条的隐藏和显示
另外,在本版中WebOffice2004只负责编辑Word或者Excel的工作,不负责向服务器数据库传输数据和从服务器数据库下载数据,为此,我们自行研发了一套基于纯Java的客户端上传控件和下载控件。
客户端上传控件:主要用来向服务器端传输数据,支持标准的 RFC 1867 文件传输协议。服务器端只需使用向aspupload等上传控件接收数据即可。 原有的控件所采取的机制是客户端直接连接服务器的数据库,这样做的缺点是如果服务器上存在防火墙,将不能连接数据库。这样,此控件的实用性将大大降低,而我们此次升级主要是为了解决此问题。上传控件实现了从客户端上传一个或者多个文件的问题,即可以通过在空件中隐含的上传数据,而传统的使用 <input type="file" name="file1">这种客户端上传技术由于受到安全方面的限制,程序不能对file控件赋值,而我们的 上传控件解决了此难题,而且,我们的上传控件兼容所有的服务器端上传控件。 下载控件:此控件使从服务器下载数据到客户端的过程中速度明显的提高了,而且,有进度条显示,让客户直到数据下载的进程。使用上面的两个控件后,我们可以很容易的把客户端编辑的word文档很容易的保存到服务器端的数据库中。
本产品支持所有版本的word,简单易用并附有完整的例子,很方便,如果有意,请发邮件到[email protected]索取试用版和完整的asp例子本产品每套只需500元。注意:试用版只能在本地机上免费使用2个月,功能跟正式版一样。
email;[email protected]
联系人:叶先生
Microsoft Visual C# for Applications 这个引用我怎么找不到