Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


When a user requests an Excel document, you can first check to see if there is new data. If there is, you can generate a new report and save it to disk. You can then stream that file to the user. We have a KB article which describes how to stream a file to the user that was previously saved to the disk with ExcelWriter.

Apply Styles to Columns and Rows, not Cells and Areas

Every time Cell.Style is accessed, ExcelWriter instantiates a separate Style object. To reduce file size bloating, we recommend using Global styles and setting styles on groups of cells. For details, see Effective Use of Styles

Applying a style to an Area also creates style objects for each individual cell in the Area.  However, if you apply a style to a column or row, there will be only one formatting record for the entire column or row, which is much more efficient.  Use ColumnProperties.Style or RowProperties.Style

Use InsertRows or InsertColumns instead of InsertRow or InsertColumn

The Worksheet class has both an InsertRows and an InsertRow method, InsertColumns, InsertRow, and InsertColumn methods. If you are only inserting one row, then you should use InsertRow; however, if you are inserting multiple rows, you should make one call to InsertRows and pass the number of rows that you want to insert. The same applies for columns. For example:

Code Block
 //Where you want to insert new rows
int atRow = 10;

//Determine how many rows you'll need to insert
int numRowsToInsert = 4;

//Insert the desired number of rows. This will be much faster
//than multiple calls to InsertRow.
ws.InsertRows(atRow, numRowsToInsert);