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. 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!
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.
精彩评论