开发者

Passing in Tab name for CSV excel sheet

开发者 https://www.devze.com 2023-02-04 22:08 出处:网络
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 开

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号