I create some .csv file and fill in with export data. This is my code:
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");
}
}
Then this file downloaded and I see all export data. This .csv file have only one sheet with data. My target is to create another additional sheet in this .csv file with another data. I don't know how to do it!
Thanks!