Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Response.ContentType在Excel中创建多个选项卡_C#_Excel_Httpresponse - Fatal编程技术网

C#Response.ContentType在Excel中创建多个选项卡

C#Response.ContentType在Excel中创建多个选项卡,c#,excel,httpresponse,C#,Excel,Httpresponse,我正在用C#生成一个Excel报告,需要在Excel文件中添加第二个包含参考数据的选项卡。如何在不使用ClosedXML的情况下实现这一点 Response.AddHeader("content-disposition", "attachment; filename=" + fname); Response.ContentType = "application/vnd.ms-excel"; var writer = new System.IO.StringWriter(); var htmlTe

我正在用C#生成一个Excel报告,需要在Excel文件中添加第二个包含参考数据的选项卡。如何在不使用ClosedXML的情况下实现这一点

Response.AddHeader("content-disposition", "attachment; filename=" + fname);
Response.ContentType = "application/vnd.ms-excel";
var writer = new System.IO.StringWriter();
var htmlTextWriter = new HtmlTextWriter(writer);
dataGrid.RenderControl(htmlTextWriter);
Response.Write(writer.ToString());
Response.End();

你不能。你在这里所做的只是发送HTML,并期望Excel为你转换。你不能。您在这里所做的只是发送HTML,并期望Excel为您转换它。