Re-size Excel columns

  • Thread starter Thread starter RP
  • Start date Start date
R

RP

I am exporting certain records to Excel 2007 using C# code. I want to
adjust the cell width accordingly so that when the record gets
transferred to a cell, it is clearly visible.

I want to increase the height and width of the Excel cell at run-time.
 
RP,

You should be able to access the column properties through the
automation model. How are you performing the export? Are you using
Automation (accessing the Application object and the Workbook/Worksheets)?

If you are exporting to 2007 (and only 2007) then you can probably forgo
the Automation model and set the width directly in the XML that makes up the
sheet. It's massive, but you can probably look in the spreadsheet ML
specification and find the element/attribute for the column width in the XML
you have to set.
 
What is the best approach to export to Excel 2007? I am using
application object.

RP,

You should be able to access the column properties through the
automation model. How are you performing the export? Are you using
Automation (accessing the Application object and the Workbook/Worksheets)?

If you are exporting to 2007 (and only 2007) then you can probably forgo
the Automation model and set the width directly in the XML that makes up the
sheet. It's massive, but you can probably look in the spreadsheet ML
specification and find the element/attribute for the column width in the XML
you have to set.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I am exporting certain records to Excel 2007 using C# code. I want to
adjust the cell width accordingly so that when the record gets
transferred to a cell, it is clearly visible.
I want to increase the height and width of the Excel cell at run-time.
 
Back
Top