【问题标题】:How to export csv as a zip file in c#如何在c#中将csv导出为zip文件
【发布时间】:2023-03-23 09:34:01
【问题描述】:

我要创建一个CSV 并在其中写入信息然后下载它。现在我必须将其下载为 zip 格式。

 public  void WriteToCSV(List<DeviceModel> DeviceList)
    {
        string attachment = "attachment; filename=DeviceModel.csv";
        Response.Clear();
        Response.ClearHeaders();
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "text/csv";
        Response.AddHeader("Pragma", "public");
        WriteColumnName();
        foreach (DeviceModel Device in DeviceList)
        {
            WriteDeviceInfo(Device);
        }
      Response.End();
    }

【问题讨论】:

标签: c# asp.net asp.net-mvc csv


【解决方案1】:

您可以为此使用库:

http://dotnetzip.codeplex.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-18
    • 2018-07-31
    • 2018-02-15
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2018-07-23
    相关资源
    最近更新 更多