传入 CSV Excel 工作表的选项卡名称
我在将“工作表”选项卡重命名为任何文件名时遇到问题。这样做的问题是,如果用户意外下载工作表两次,Windows 会将 template(1).csv 附加到文件中,以保持其下载目录中的唯一性。在 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();
谢谢!
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. When opened in Excel, this sheet has a tab name of template(1).csv - as it assumes the file name.
//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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 CSV 文件不包含工作表,Excel 只是让它们看起来像包含工作表一样。
无论 .csv 文件的名称是什么,Excel 都会使用它来填充工作表名称。
The problem is that CSV files do not contain sheets, Excel just makes them look like they do.
Whatever the name of the .csv file is, excel will use that to populate the sheet name thingy.