Click here to Skip to main content
15,885,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to export a data set:
DataSet ds = new DataSet("tabless");
ds.Tables.Add(table01);
ds.Tables.Add(table02);
ds.Tables.Add(table03);

it contains 3 data table, each one of them is:
C#
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));

then i added data to each table ...
table01.Rows.Add("A", 0, 84100, 2, null, 9);

So I need to export them to an excel sheet with number format and comma separator.
Like when value = -200000 will be (200,000) with red color and value 300000 will be 300,000 and apply this to each table in the work sheet. For more info check the below photo:http://postimg.org/image/lj55lz6ib/[^]
Posted

1 solution

you could use
Worksheets("Sheet1").Range("A1").Formula = "=Text(value, ""#,##0.000;(#,##0.000);"")"

for value = -200000 will be (200,000) format and for color
and
if value <0 then
Worksheets("Sheet1").Range("A1").Interior.Color = RGB(255, y, x)
end if
 
Share this answer
 
Comments
Dev_Fady... 26-Feb-15 2:12am    
how to export this data to excel first and then added this prop .. ??
Abdulnazark 26-Feb-15 3:30am    
see below link
http://csharp.net-informations.com/excel/csharp-open-excel.htm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900