Uploaded image for project: 'ZK Spreadsheet'
  1. ZK Spreadsheet
  2. ZSS-1132

ExcelXlsxExporter always exports columns as custom width

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.8.1
    • Fix Version/s: 3.8.2
    • Component/s: None
    • Security Level: Jean
    • Labels:
      None
    • gh.sprint.customfield.default.name:
      Sprint 1

      Description

      Problem description

      please check attached images.

      Root Cause

      protected void exportColumnArray(SSheet sheet, Sheet poiSheet, SColumnArray columnArr) {
      		XSSFSheet xssfSheet = (XSSFSheet) poiSheet;
      		
              ...
          	col.setCustomWidth(true);
              ...
      }
      

      Debug info

      • By checking columWidth2007.xlsx, columnWidth2011.xlsx, only custom width column has

        Workaround

        public class PatchedExcelXlsxExporter extends ExcelXlsxExporter{
        
        	@Override
        	protected void exportColumnArray(SSheet sheet, Sheet poiSheet,
        			SColumnArray columnArr) {
        	XSSFSheet xssfSheet = (XSSFSheet) poiSheet;
        		
                CTWorksheet ctSheet = xssfSheet.getCTWorksheet();
            	if(xssfSheet.getCTWorksheet().sizeOfColsArray() == 0) {
            		xssfSheet.getCTWorksheet().addNewCols();
            	}
            		
            	CTCol col = ctSheet.getColsArray(0).addNewCol();
                col.setMin(columnArr.getIndex()+1);
                col.setMax(columnArr.getLastIndex()+1);
            	col.setStyle(toPOICellStyle(columnArr.getCellStyle()).getIndex());
            	col.setCustomWidth(sheet.getDefaultColumnWidth() != columnArr.getWidth()); //patch
            	col.setWidth(UnitUtil.pxToCTChar(columnArr.getWidth(), AbstractExcelImporter.CHRACTER_WIDTH));
            	col.setHidden(columnArr.isHidden());
        	}
        }
        

      But for actual solution, we would consider custom width flag like:
      col.setCustomWidth(columnArr.isCustomWidth() || sheet.getDefaultColumnWidth() != columnArr.getWidth());
      Because users may adjust the width to equal to default width.

        Attachments

        1. cssRuleOverflow.png
          cssRuleOverflow.png
          12 kB
        2. customWidth2007.xlsx
          8 kB
        3. customWidth2011.xlsx
          27 kB
        4. ie9RenderingIssue.png
          ie9RenderingIssue.png
          17 kB

          Issue Links

            Activity

              People

              • Assignee:
                henrichen henrichen
                Reporter:
                hawk hawk
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: