2014-01-14 29 views
0

我创建了一些.csv文件并填写了导出数据。这是我的代码:用.csv文件中的数据创建新工作表

public void ExportGoodList(int id) 
     { 
      List<LineItem> lineItems = _lineItemService.FindAllByApplicationId(id).ToList(); 
      Response.Clear(); 
      Response.AddHeader("Content-Disposition", "attachment; filename=Carnet" + id + ".csv"); 
      Response.Flush(); 
      Response.Write("Item Description"); 
      Response.Write(","); 
      Response.Write("No. of Pieces (numbers only are allowed)"); 
      Response.Write(","); 
      Response.Write("Weight/Volume (numbers only are allowed)"); 
      Response.Write(","); 
      Response.Write("\"Unit of Measure (the following values are allowed only: g, kg, t, l)\""); 
      Response.Write(","); 
      Response.Write("Value (in GBP) (numbers only are allowed)"); 
      Response.Write(","); 
      Response.Write("Country of Origin (the codes of the countries are allowed only)"); 
      Response.Write(","); 
      Response.Write(" Goods Type ID (numbers only are allowed)"); 
      Response.Write(","); 
      Response.Write("\n"); 
      foreach (var item in lineItems) 
      { 
       Response.Write(SanitizeData(item.Description)); 
       Response.Write(","); 
       Response.Write(SanitizeData(item.NumberOfPieces)); 
       Response.Write(","); 
       Response.Write(SanitizeData(item.Quantity)); 
       Response.Write(","); 
       Response.Write(SanitizeData(item.QuantityUnits)); 
       Response.Write(","); 
       Response.Write(SanitizeData(item.ItemValue)); 
       Response.Write(","); 
       Response.Write(SanitizeData(item.CountryOfOrigin)); 
       Response.Write(","); 
       Response.Write(SanitizeData(_goodsTypeService.GoodsTypeIdToUserDefinedId(item.GoodsType))); 
       Response.Write("\n"); 
      } 
     } 

然后将此文件下载和我看到所有的出口数据。该.csv文件只有一个包含数据的工作表。我的目标是用另一个数据在这个.csv文件中创建另一个附加工作表。我不知道该怎么做!

谢谢!

回答

相关问题