< cfspreadsheet > and "...". "maximum number of fonts has been exceeded" error in Excel 2007

A client and I both live the same error message when you open a spreadsheet generated by ColdFusion version 9.0.0 (deployment of Windows). The generated workbook is relatively complex, with a summary tab and about 25 other tabs.

Here is the exact error that opens in Excel 2003 and 2007:

Some text formatting may have changed in this file, because the maximum number of fonts has been exceeded. It can help to close other documents and try again.

This only happens when the amount of data stored in the document is larger (but I can't tell you exactly how big the document must do in order to start to trigger this error). I'm no formatting with fonts, which explains why this error is confusing for me. There are some columns I'm formatting in different data formats in each tab, things like this:

<cffunction name="formatEventSheet" hint="Formats a given row in a spreadsheet and returns the spreadsheet object.">
    <cfargument name="spreadsheet" hint="Spreadsheet object to manipulate. Active sheet must be set to sheet to modify.">
 
    <cfset var loc = StructNew()>
 
    <!--- Currency formatting --->
    <cfset loc.currencyFormat = StructNew()>
    <cfset loc.currencyFormat.dataFormat = "($##,####0.00);($##,####0.00)">
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 5)>
 
    <cfreturn arguments.spreadsheet>
 
</cffunction>


<cffunction name="formatEventSummarySheet" hint="Formats a given row in a spreadsheet and returns the spreadsheet object.">
    <cfargument name="spreadsheet" hint="Spreadsheet object to reference. Active sheet must be set to sheet to modify.">
 
    <cfset var loc = StructNew()>
 
    <!--- Currency formatting --->
    <cfset loc.currencyFormat = StructNew()>
    <cfset loc.currencyFormat.dataFormat = "($##,####0.00);($##,####0.00)">
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 4)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 6)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 8)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 10)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 12)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 14)>
    <cfset SpreadsheetFormatColumn(arguments.spreadsheet, loc.currencyFormat, 16)>
 
    <cfreturn arguments.spreadsheet>
 
</cffunction>

I can post some more code if need be (there are lots of it), but I was wondering if anyone has run across this in general and they did to remedy.

Post edited by: Chris Peters - added syntax highlighting.

Here is some information from a post on experts-exchange website. It seems that this could be applicable in your case...

This error is generated when you have maxed out the internal formatting tables.

Here are a few notes on the reduction of the use of the entries in the table formatting...

A common misconception is that at some point in formatting any range of contiguous cells results in smaller workbooks. It is, for the most part, is not true. The only time where excel keeps the size of the workbook is when a column of cells is formatted to a starting cell to the bottom of the worksheet. The starting cell can be on a line, but the last cell must be on the last line of the spreadsheet. Layout of several contiguous columns at the bottom of the worksheet gives the same result as formatting each column individually.

Note that when formatting of the horizontal borders in a column, do not set the bottom as border doing so will require as much file size as if every cell in the column have been formatted separately. Set inside horizontal border only.

A quick test shows this behavior. Create two new workbooks. In the first, select the A2:A65536 cells, set the background color and save. In the second, select the A2:A65535 cells, set the background color and save. Using Windows File Explorer, look at the size of the files of the two workbooks. Note that the first workbook is approximately 12 KB in size, while the second is more than 2 MB.

Formatting columns of cells in this way has another advantage: the used range is unaffected. In other words, if the formatting of the cells A2:A65535 the used range is set to A2:A65525. However, if the A2:A65536 cells are formatted, the used range is affected. Note that this is not true in line or horizontal direction. In other words, a line in the format of the column at the right IV reset the range used to include column IV. Also, note that this problem has been corrected in Excel 2003 and lines behave like columns in 2003 regarding the used range.

Another interesting aspect of formatting of columns to the bottom of the worksheet is that the completed workbook file size advantage is not compromised by reformatting the individual cells within the larger range. For example, if A2:A65536 of cells are formatted as cell A1000 is then formatted another way, the size of the workbook file continues to be small.  This is true even if cell A65536 got rid of all formatting. Note that the unformatted cells consume space because they are exceptions to the first formatting and so services provided by the formatting at the end of the worksheet are eroded as more and more cells are positioned to other formats or erased formats.

Tags: ColdFusion

Similar Questions

Maybe you are looking for