简体   繁体   English

传入CSV Excel工作表的标签名

[英]Passing in Tab name for CSV excel sheet

I'm having a problem with the Worksheet tab being renamed to whatever the file name is. 我在将工作表选项卡重命名为文件名时遇到问题。 The problem with this is if a user accidentally downloads the sheet twice, Windows appends template(1).csv to the file to maintain uniqueness in their download directory. 这样做的问题是,如果用户不小心两次下载了工作表,则Windows会将template(1).csv附加到文件中,以保持其下载目录中的唯一性。 When opened in Excel, this sheet has a tab name of template(1).csv - as it assumes the file name. 在Excel中打开时,此工作表的选项卡名称为template(1).csv-假定为文件名。

//This code correctly downloads a CSV file - but how can I pass in the tab name???
            context.Response.Clear();
            context.Response.ContentType = "text/comma-separated-values";//"application/vnd.ms-excel";
            context.Response.AppendHeader("Content-Disposition", "attachment;filename=template.csv");
            context.Response.Write(csvString);
            context.Response.End();

Thanks! 谢谢!

The problem is that CSV files do not contain sheets, Excel just makes them look like they do. 问题是CSV文件不包含工作表,Excel只是使它们看起来像它们。

Whatever the name of the .csv file is, excel will use that to populate the sheet name thingy. 无论.csv文件的名称是什么,Excel都将使用它来填充工作表名称whaty。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM