導航:首頁 > 文字圖片 > 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圖片相關的資料

熱點內容
中國女星漏過點的電影 瀏覽:90
一部電影血腥食人族 瀏覽:708
美景之景許娜京 瀏覽:854
關於阿爾卑斯山的電影 瀏覽:70
午馬推.古裝理電影在線免費觀看 瀏覽:918
情歌戀曲法國在線觀看 瀏覽:495
李采潭電影合集 瀏覽:457
日韓大尺度電影推薦 瀏覽:16
誰有免費的看片網站 瀏覽:130
外國的歌曲電影動畫有哪些 瀏覽:982
什麼網站可以看小電影 瀏覽:686
web日本輕小說資源網站 瀏覽:32
被鬼強行發生性關系電影 瀏覽:449
日本的一部電影,女主是鋼琴家男主是男僕 瀏覽:525
帶肉的仙俠類小說 瀏覽:547
日本電影有肉 瀏覽:524
全篇都是肉的現言小說青梅竹馬 瀏覽:845
啄木鳥全系列名字 瀏覽:44
神仙恐怖電影 瀏覽:240
年少懵懂的男孩愛上自己的老師電影 瀏覽:415