Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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# 如何为C生成的Excel电子表格设置工作表名称?_C#_.net_Excel_Worksheet - Fatal编程技术网

C# 如何为C生成的Excel电子表格设置工作表名称?

C# 如何为C生成的Excel电子表格设置工作表名称?,c#,.net,excel,worksheet,C#,.net,Excel,Worksheet,我们在C#net网站上通过编写一个HTML表格来生成Excel电子表格。这很好,但是工作表名被设置为与文件名相同 有没有其他的办法来解决这个问题?导入时,我们需要特定的图纸名称 代码: 通过创建表格并将内容类型设置为Excel,您无法定义工作表名称,也无法创建更多工作表 您可以使用生成完整的Excel工作簿,但您的客户端需要使用来处理Office 2007文件格式。或者您可以使用旧的SpreadsheetML文件类型,但在图表等方面会受到限制。这里有一个参考:np:)我发现评论的问题是,当你写评

我们在C#net网站上通过编写一个HTML表格来生成Excel电子表格。这很好,但是工作表名被设置为与文件名相同

有没有其他的办法来解决这个问题?导入时,我们需要特定的图纸名称

代码:


通过创建表格并将内容类型设置为Excel,您无法定义工作表名称,也无法创建更多工作表


您可以使用生成完整的Excel工作簿,但您的客户端需要使用来处理Office 2007文件格式。

或者您可以使用旧的SpreadsheetML文件类型,但在图表等方面会受到限制。这里有一个参考:np:)我发现评论的问题是,当你写评论的时候,你完全忘记了对答案进行投票(如果适用的话)!
string filename = String.Format( "{0}-CopyDataBack_{1}.xls", Master.EventID.ToString(), DateTime.Now.ToString( "dd-MM-yy_HHmm" ) );

Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=" + filename );
Response.Charset = "";
this.EnableViewState = false;

System.Text.StringBuilder tableOut = new System.Text.StringBuilder();
// ... Create an HTML table in a StringBuilder ...
Response.Write( tableOut );
Response.End();