Page tree

Versions Compared

Key

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

...

Use InsertRows/Columns Instead of InsertRow/Column

Why What might cause this might to happen:

  • Someone is adding multiple rows into a template file yet is unaware that both InsertRow and InsertRows are legitimate functions (same with InsertColumn(s)).

Issues with Why this method causes issues:

  • Every time a call is sent for InsertRow, InsertRows, InsertColumn, DeleteRow, etc., it requires the updating of the entire grid to calculate the new position of all rows/columns beyond the adjusted ones.
  • Grid updates also require that any formulas that point to something beyond the adjusted position have to be updated to compensate.

...

Avoid Calling AutoFitWidth on a Large Amount of Data

Why What might cause this might to happen:

  • As AutoFitWidth sets the width of a column to just beyond the length of the longest cell, and as such can be seen as a very simple way to format items.

Issue with Why this method causes issues:

  • Since AutoFitWidth has to loop through all of the values in a column to determine which has the longest length, it often becomes very time consuming to call it on larger data sets.

...

  • AutoFitWidth can still be called on very small amounts of data, but if it's even debatable whether a data might be too large, it should be avoided.
  • Determine a likely possible max length for populated cells, and adjust column widths beforehand (may not look as nice, but runs much better).
  • You can loop through the DataTable manually.  Although you are still looping through all the data, DataTables are simpler to loop through than entire worksheets.
  • Be wary of the fact that datamarkers allow the order of columns in the data source and in the resulting worksheet to be different.  This method only workers if you are sure of a column's location in both the original DataTable and in the output file.
  • If estimating, remember to account for any formatting that may be applied, such as currency formatting.

Cache Frequently

Why What might cause this might to happen:

  • Most documents are set up this way by default, as is in many cases it is not much of an issue.

Issue with Why this method causes issues:

  • A document that is called a lot and is set to run whenever someone calls it may result in issues if it gets to be large enough in size, since it has to retrieve the information each time.

...