我正在處理從我的gridview生成動態excel文件的c#項目。默認情況下,我如何生成類型爲'文本'而不是'常規'的Excel文件
,當我成功生成是將所有的數據到Genaral
類型的文件,但我需要所有的excel文件數據到Text
格式,
我怎麼能這樣做?當我需要進一步使用該文件報告的目的和需要Text
類型
以下是我的Excel文件生成的C#代碼:
private void ExportGridView()
{
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
// Render grid view control.
gvFiles.RenderControl(htw);
// Write the rendered content to a file.
string renderedGridView = sw.ToString();
File.WriteAllText(@"C:\test\ExportedFile.xls", renderedGridView);
}
我想我需要使用Microsoft.Office.Interop.Excel
和我可以指定類型也喜歡生成Text
此外,我搜索像我們可以生成它像一個像HTML包含,並使其出類拔萃。
任何人都可以幫助我嗎?
如果你想使用'Microsoft.Office.Interop.Excel',你需要在機器上安裝MS Office。這可以嗎? – 2013-03-01 13:32:19
是的,這對我來說很好,任何人都可以請幫我 – Neo 2013-03-01 13:36:06