Creating Excel File -- Autofit cells
-
Hi all. I am using a class found here http://www.codeproject.com/database/cspreadsheet.asp to create an excel spreadsheet ( i believe it uses ODBC ) It works great except I cannot, from my code, get the cells to autofit. That is, when you load up the file in Excel, a lot of the contents of the cells get cut off, because the cell is not big enough. I need to be able to tell it to autofit (automatically through code) or be able to specify the width of each column of cells. If I bring up the file in excel, and select all of the cells, then click on Column->Autofit, it makes it look right instantly ... However, I am planning on rolling out a program that generates reports and I don't want to have to tell the users that they have to do this every time they open a report. Any help in the right direction would be appreciated! -Shultas
-
Hi all. I am using a class found here http://www.codeproject.com/database/cspreadsheet.asp to create an excel spreadsheet ( i believe it uses ODBC ) It works great except I cannot, from my code, get the cells to autofit. That is, when you load up the file in Excel, a lot of the contents of the cells get cut off, because the cell is not big enough. I need to be able to tell it to autofit (automatically through code) or be able to specify the width of each column of cells. If I bring up the file in excel, and select all of the cells, then click on Column->Autofit, it makes it look right instantly ... However, I am planning on rolling out a program that generates reports and I don't want to have to tell the users that they have to do this every time they open a report. Any help in the right direction would be appreciated! -Shultas
Hi ODBC, ADO or OLEDB will only allow you to manipulate data in and out Excel files, to go beyond that, you should use Automation, then you will be able to do, programmatically, anything you have to do. You can take a look here to start, SAMPLE: XLCLIENT: Automation Client for Excel, also search the MSDN for more info. Fabian