导航:首页 > 文字图片 > aspnet导出word图片

aspnet导出word图片

发布时间:2022-05-22 01:00:08

‘壹’ 我想用c#把整个窗体导出word文档

在退格键的右面,Insert键的上面,有一个"Print Screen SysRq"键,一般简称为PrintScreen键,单独按PrintScreen键可复制当前屏幕内容,按下Alt键的同时按下PrintScreen键可复制当前窗口内容,然后打开Word或画图程序,Ctrl+V或者点鼠标右键--粘贴即可。

‘贰’ 将asp.net(c#)中textbox的内容导出到word中

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class EceDoc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
this.eceDoc("20090228144600", "application/vnd.doc");
}
private void eceDoc(string FileName, string FileType)
{
//清除反冲区的内容
Response.Clear();
//设置输出流的HTTP字符集
Response.Charset = "gb2312";
//将一个HTTP头添加到输出流
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".doc");
//设置输出的HTTP MIME类型
Response.ContentType = FileType;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append(this.TextBox1.Text);

//把字符数组写入HTTP响应输出流
Response.Write(sb.ToString());
//发送完,关闭
Response.End();

}

}

‘叁’ asp.net(C#) 导出到word excel [100分]

ASP.NET(C#)将数据导出到Word或Excel命名空间:using
System.IO;
using
System.Text;将DataGrid的数据导出到Excel
string
excelname="excel文件名";
HttpContext.Current.Response.Charset
=
"GB2312";
HttpContext.Current.Response.ContentEncoding
=
Encoding.UTF8;
HttpContext.Current.Response.ContentType
=
"application/ms-excel";
HttpContext.Current.Response.AppendHeader("Content-disposition",
"attachment;filename="
+
excelname
+
".xls");
dr1.Page.EnableViewState
=
false;
StringWriter
sw
=
new
StringWriter();
HtmlTextWriter
tw
=
new
HtmlTextWriter(sw);
dr1.RenderControl(tw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
将DataGrid的数据导出到Word
string
excelname="word文件名";
HttpContext.Current.Response.Charset
=
"GB2312";
HttpContext.Current.Response.ContentEncoding
=
Encoding.UTF8;
HttpContext.Current.Response.ContentType
=
"application/ms-winword";
HttpContext.Current.Response.AppendHeader("Content-disposition",
"attachment;filename="
+
excelname
+
".doc");
dr1.Page.EnableViewState
=
false;
StringWriter
sw
=
new
StringWriter();
HtmlTextWriter
tw
=
new
HtmlTextWriter(sw);
dr1.RenderControl(tw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();

‘肆’ 如何使用c#.net将数据和文本导出到office word,并按一定的格式自动生成目录

我也正在做这个,
添加引用->COM->Microsoft Word 11.0 Object Library

然后利用word中的方法了,网上有例子,这里就不给你粘贴了,

‘伍’ C# winform读取word中的图片、文字并保存

你的docWord是不是null
//
Word 开发人员参考
Paragraphs集合对象
所选内容、范围或文档中的Paragraph对象的集合。

上面是官方API说明,意思是【选择】的段落内容,所以遍历前先全选文章。

官方api可以在word中查看
office2007:视图-宏-查看宏-开发帮助
office2003:工具-宏-查看宏-开发帮助

示例

本示例将活动文档第一节中所有段落集合的行距设置为单倍行距。

Visual Basic for Applications

ActiveDocument.Sections(1).Range.Paragraphs.LineSpacingRule = _
wdLineSpaceSingle
本示例将选定内容的首段的行距设置为双倍行距。

Visual Basic for Applications

Selection.Paragraphs(1).LineSpacingRule = wdLineSpaceDouble

‘陆’ ASP.NET中如何从数据库读取数据后,生成WORD文档,并保存在某个目录下(C#)

如果生产后不改了。直接打印到pdf,word的Image Writer,生成文件打印。

‘柒’ 使用aspnet将word表单导入系统中形成web表单,在系统中完成web表单,然后将web表单再导出到word

web表单要有个东西来接收
用Grid
DataSetOpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "Excel files(*.xls)|*.xls";ExcelIO excelio = new ExcelIO();if(openFile.ShowDialog()==DialogResult.OK)
{
if(excelio!=null)
excelio.Close(); excelio = new ExcelIO(openFile.FileName);
object[,] range = excelio.GetRange();
excelio.Close();
DataSet ds = new DataSet("xlsRange"); int x = range.GetLength(0);
int y = range.GetLength(1); DataTable dt = new DataTable("xlsTable");
DataRow dr;
DataColumn dc;

ds.Tables.Add(dt); for(int c=1; c<=y; c++)
{
dc = new DataColumn();
dt.Columns.Add(dc);
}

object[] temp = new object[y];

for(int i=1; i<=x; i++)
{
dr = dt.NewRow(); for(int j=1; j<=y; j++)
{
temp[j-1] = range[i,j];
}

dr.ItemArray = temp;
ds.Tables[0].Rows.Add(dr);
} dataGrid1.SetDataBinding(ds,"xlsTable");

if(excelio!=null)
excelio.Close();
}

//导出
private void ExportToWord(DataTable dt, string targetWordFile)
{
object oMissing = System.Reflection.Missing.Value;

//Start Word and create a new document.
Word._Application oWord = null;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = false;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);

//Insert a paragraph at the beginning of the document.
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = dt.Rows[0]["mname"].ToString(); //会议名称!
oPara1.Range.Font.Bold = 1;
oPara1.Range.Font.Size = 18;
oPara1.Range.Font.Color = Word.WdColor.wdColorRed;
oWord.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();

object oMissing2 = System.Reflection.Missing.Value;

//Insert a paragraph at the end of the document.
Word.Paragraph oPara2;
oPara2 = oDoc.Content.Paragraphs.Add(ref oMissing2);
oPara2.Range.Text = dt.Rows[0]["datetime"].ToString(); //会议时间
oPara2.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
oPara1.Range.Font.Color = Word.WdColor.wdColorBlack;
oPara2.Range.Font.Bold = 1;
oPara2.Range.Font.Size = 14;
oPara2.Format.SpaceAfter = 24;
oPara2.Range.InsertParagraphAfter();

int rowcount = dt.Rows.Count + 1; // 含标题行,及所有用户行 表格总行//Insert a 3 x 4 table, fill it with data, and make the first row
//bold and italic.
//Insert another paragraph.
Word.Paragraph oPara4;
oPara4 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara4.Format.SpaceAfter = 24;
oPara4.Range.Font.Bold = 0;
oPara4.Range.Font.Size = 12;
oPara4.Range.InsertParagraphAfter();

Word.Table oTable;
Word.Range wrdRng = oPara4.Range;

‘捌’ c#如何从word文档中提取图片

从菜单中选择“文件-另存为”,选择文件类型为WEB页,然后保存。在文件夹中找到保存WEB页的文件夹,我们会发现WORD、POWERPOINT自动生成了一个名字为原文档标题.files的文件夹,原文档中的所有图片已经自动顺序命名,并保存在这个*.files文件夹中,其中还包括POWERPOINT文档的背景图片。

‘玖’ 如何使用C#从word文档中提取图片

详细步骤与代码:
步骤1 : 添加引用。
新建一个Visual C#控制台项目,添加引用并使用如下命名空间:
?

1
2
3
4

using System;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

步骤2 : 新建一个word文档对象并加载需要提取图片的word文档。
Document document = new Document("法国景点.docx ");
步骤3 : 遍历文档中的所有section,找到图片,将它们提取出来并保存。
?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

int index = 0;
//获取文档的section
foreach (Section section in document.Sections)
{
//获取section中的段落
foreach (Paragraph paragraph in section.Paragraphs)
{
//获取段落中的文档对象
foreach (DocumentObject docObject in paragraph.ChildObjects)
{
//对对象的type进行判断,如果是图片,就提取出来
if (docObject.DocumentObjectType == DocumentObjectType.Picture)
{
DocPicture picture = docObject as DocPicture;
//给图片命名
String imageName = String.Format(@"images\Image-{0}.png", index);
//保存图片
picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
index++;
}
}
}
}

提取出来的图片:

全部代码:
?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

using System;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System.Drawing;
namespace Extract_image_from_word
{
class Program
{
static void Main(string[] args)
{
Document document = new Document("法国景点.docx");
int index = 0;
foreach (Section section in document.Sections)
{
foreach (Paragraph paragraph in section.Paragraphs)
{
foreach (DocumentObject docObject in paragraph.ChildObjects)
{
if (docObject.DocumentObjectType == DocumentObjectType.Picture)
{
DocPicture picture = docObject as DocPicture;
String imageName = String.Format(@"images\Image-{0}.png", index);
picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
index++;
}
}
}
}
}
}
}

总结:
这里我使用的是E-iceblue公司的免费 word 组件,它除了可以从文档中提取图片,还可以提取文本,这里我只写了提取图片的,提取文本的也差不多

‘拾’ C#如何实现把word文档内的图片提取出来,另存为jpg或gif格式

如果要在.net中控制word中的内容,只有使用Microsoft Word Object Library的方式。使用word的对象模型,遍历其中的图片对象,然后使用 SaveAs 的方式保存。

--------------------
SaveAs 使用示例:
Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document doc;
object nothing = System.Reflection.Missing.value;
doc = word.Documents.Add(ref nothing,ref nothing,ref nothing,ref nothing);
doc.Paragraphs.Last.Range.Text = this.richTextBox1.Text;
object myfileName = FileName;
//将WordDoc文档对象的内容保存为doc文档
doc.SaveAs(ref myfileName,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing);
//关闭WordDoc文档对象
doc.Close(ref nothing,ref nothing,ref nothing);
//关闭WordApp组件对象
word.Quit(ref nothing,ref nothing,ref nothing);

阅读全文

与aspnet导出word图片相关的资料

热点内容
热血街区在哪可以看 浏览:897
泰国血腥暴力格斗电影 浏览:330
《兄妹禁忌之恋》电影 浏览:584
悦跑日签怎么下图片 浏览:815
洗洁精瓶子怎么做花盆的图片 浏览:585
有一部美国电影叫什么妖姬 浏览:645
怎么看网络没有打马赛克 浏览:144
邪杀女配角是谁 浏览:775
神鼠电影娃女娘的故事 浏览:667
类似比基尼空姐的电影 浏览:546
手机删除的图片怎么找回来免费 浏览:998
苹果怎么看图片详情 浏览:20
开心的文字图片大全 浏览:945
jeep指南者图片大全 浏览:18
双层子母床图片及价格 浏览:768
女孩和鹿的图片 浏览:404
美国劳改犯衣服图片 浏览:279
卡通猫和老鼠文字图片壁纸 浏览:568
踏山河选自哪部电视剧 浏览:119