以数字格式导出数据 table 到 excel sheet

Export data table to excel sheet with number format

我需要导出一个数据集:

DataSet ds = new DataSet("tabless");
ds.Tables.Add(table01);
ds.Tables.Add(table02);
ds.Tables.Add(table03);

它包含3个数据table,每一个是:

table01.Columns.Add("Branch",typeof(string));
table01.Columns.Add("Today", typeof(double));
table01.Columns.Add("MTD",typeof(double));
table01.Columns.Add("LM",typeof(double));
table01.Columns.Add("Differ",typeof(double),"LM-MTD");
table01.Columns.Add("YTD",typeof(double)); 

所以我需要将它们导出到具有数字格式和逗号分隔符的 excel sheet。
就像当值 = -200000 将是 (200,000) 红色时,值 300000 将是 300,000 并将其应用于作品 sheet 中的每个 table。 欲了解更多信息,请查看以下照片:

Screenshot http://postimg.org/image/lj55lz6ib/

您可以使用 NumberingFormat

        //Create a NumberingFormat 
        NumberingFormat numForm2decim = new NumberingFormat();
        numForm2decim.NumberFormatId = 1u;
        numForm2decim.FormatCode = StringValue.FromString("0.00");  

        //Use it in a CellFormat
        CellFormat cellformatNumber2Decim = new CellFormat();            
        cellformatNumber2Decim.NumberFormatId = numForm2decim.NumberFormatId;
        cellformatNumber2Decim.ApplyNumberFormat = true;

        //And apply the cellFormat to your Cell throw the StyleIndex Property