c# - OLEDB Excel file format -


string strconn = "provider=microsoft.ace.oledb.12.0;data source=" +                   filename + ";extended properties=\"excel 12.0 xml;hdr=yes;imes=1;\"";  using (oledbconnection conn = new oledbconnection(strconn)) {     conn.open();     datatable dt = dataset.tables[0];     oledbcommand cmd = new oledbcommand(getcreatetablecommand(dt), conn);     cmd.executenonquery();      conn.close(); }  /*method - getcreatetablecommand returns -  {create table [results] ([name1] string,[name2] string,[name3] string,[name4] string}*/ 

output good. issue is- want excel columns have proper width. in other words, want wider columns wider space required write columns' name. how resize column?

the ace driver has no control on how excel displays value. if want control cell formatting, need use openxml sdk, third party add-in jetcell, or excel automation using primary interop assembly, chances don't want go last option.


Comments