tracker issue : CF-4066274

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: spreadsheetObject.columnCount

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 09/29/2015

Components: Document Management

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on May 17, 2018 using build 2016.0.01.298513
Currently a spreadsheet object has a rowCount key but does not have a columnCount key. This complicates the formatting of only defined cells.

Steps to reproduce:

1) Run this:

<cfscript>
  mySpreadsheet = spreadsheetNew("mySheet", false);
  spreadsheetAddRows(mySpreadsheet, ["one,two,three","four,five,six","seven,eight,nine"], 1, 1);
  spreadsheetFormatCellRange(mySpreadsheet, {locked=false}, 1, 2, mySpreadsheet.rowCount, 2);//format only the defined cells
  spreadsheetFormatCellRange(mySpreadsheet, {locked=false}, 2, 1, 2, getSpreadsheetColumnCount(mySpreadsheet, "mySheet"));//format only the defined cells
  spreadsheetWrite(mySpreadsheet, expandPath("./myspreadsheet.xls"), "", true);
  cfspreadsheet(action="read", src=expandPath("./myspreadsheet.xls"), query="q");
  writeDump(q);
  
  numeric function getSpreadsheetColumnCount(required spreadsheet, required sheetname) {//workaround (to be implemented for mySpreadsheet.columnCount per this ER)
      var result = 0;
      var sheet = ARGUMENTS.spreadsheet.getWorkbook().getSheet(ARGUMENTS.sheetname);
      for(var currentRowNum=1; currentRowNum lt ARGUMENTS.spreadsheet.rowCount; currentRowNum++) {
          result = max(result, sheet.getRow(currentRowNum).getLastCellNum());
      }
      return result;
  }
</cfscript>

2) See I wanted to only format defined cells. But spreadsheet object did not tell me how many columns there are. So, in getSpreadsheetColumnCount(), I found which row has the maximum number of *defined* cells (via getLastCellNum()) and returned the result.

This ER is to do the same as getSpreadsheetColumnCount() to populate a spreadsheet's new "columnCount" key.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4066274

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

Hi, Spreadsheet.rowCount is not a costly operation, as underlying POI library has support for the same. When we try to have similar implementation for column count, we don't have support from POI. For Spreadsheet.columnCountt the approach suggested by Aaron is one solution but it requires to iterate over all the rows in the spreadsheet and return the max no. of column.If we go by this approach the for every operation i.e. addrows, addrow, deletecolumn, deletecolumns, insertcolumn, mergecells, shiftcolumns etc we need to iterate over the rows of spreadsheet and update the column count, which will have impact on performance.
Comment by Mayur J.
5682 | October 28, 2015 02:18:54 AM GMT
Hi Mayur, Thank you for your follow-up and insight. I see that would impact performance and would like to change my request. Instead of spreadsheet.columnCount, how about a spreadsheetGetColumnCount() function and spreadsheet.getColumnCount() member function? Then all operations would not need to update the column count. The spreadsheetGetColumnCount() function could just calculate the count and return it. Thanks!, -Aaron
Comment by External U.
5683 | October 28, 2015 02:39:52 AM GMT
Hi Mayur, I see this ticket is now Closed/Fixed. What was the fix? 1) Spreadsheet.columnCount -or- 2) spreadsheetGetColumnCount() and spreadsheet.getColumnCount() Thanks!, -Aaron
Comment by External U.
5684 | November 16, 2015 02:28:31 AM GMT
*bump* I see this ticket is now Closed/Fixed. What was the fix? 1) Spreadsheet.columnCount -or- 2) spreadsheetGetColumnCount() and spreadsheet.getColumnCount()
Comment by External U.
5685 | December 04, 2015 06:05:35 AM GMT
Aaron, Both, the member function and the spreadsheet functions have been implemented: xlObj.getColumnCount SpreadsheetGetColumnCount
Comment by Piyush K.
5686 | December 21, 2015 01:15:02 AM GMT
Hi Piyush, Awesome! Thanks! -Aaron
Comment by External U.
5687 | December 21, 2015 01:21:45 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
27842 | May 17, 2018 08:18:12 AM GMT