首页 > Web开发 > 详细

.net 导出Excel

时间:2015-02-06 10:45:58      阅读:319      评论:0      收藏:0      [点我收藏+]
1、引用Interop.MSXML2 DLL , 2、录入XSL文件,注意Worksheet格式 請款單號
后台代码: XmlDocument myXml = new XmlDataDocument(ds); MSXML2.DOMDocument pXmlDocShow = new DOMDocumentClass(); pXmlDocShow.async = false; pXmlDocShow.loadXML(myXml.InnerXml); XmlDocument pXslDoc = new XmlDocument(); if (formType.Trim() == "CARR.FORM.2") { pXslDoc.Load(Server.MapPath("QueryFormsOfFeePC.xsl")); } else { pXslDoc.Load(Server.MapPath("QueryFormsOfFeeEP.xsl")); } MSXML2.DOMDocument pXslDocShow = new DOMDocumentClass(); pXslDocShow.async = false; pXslDocShow.loadXML(pXslDoc.InnerXml); string strTemp = pXmlDocShow.transformNode(pXslDocShow); int strTempBegin = strTemp.IndexOf(""); strTemp = strTemp.Remove(strTempBegin, strTempEnd - strTempBegin + 2); strTemp = @"" + strTemp; string _fileXls = DateTime.Now.ToString("yyyyMMdd"); Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.AddHeader("Content-Disposition", "attachment; filename=" + _fileXls + ".xls"); Response.ContentType = "application/ms-word"; Response.Write(strTemp); Response.End();

.net 导出Excel

原文:http://www.cnblogs.com/Chinarain/p/4276428.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!