Flexsheet cell marge like excel

Posted by: syed.mahmud on 2 March 2023, 6:42 am EST

    • Post Options:
    • Link

    Posted 2 March 2023, 6:42 am EST

    Since I cannot do the margining of the cell from excel to flexsheet, I am using the bellow function to set cell content. Is there a better way to do this? In Wijmo, can I use a binding to set the cell margin data?

    writeToWorksheet(rowIndex: number, maxRowToWritePerCall: number, worksheetPageModel, sheet, callback, self, threadId) {

    for (let i = 0; i < maxRowToWritePerCall; i++) {

    if (rowIndex >= worksheetPageModel.rows.length) {

    callback();

    return;

    }

      const row = worksheetPageModel.rows[rowIndex];
    
      if (sheet.rows[rowIndex]) {
        sheet.rows[rowIndex].visible = !row.isHidden;
      } else {
        for (let r = sheet.rows.length; r <= rowIndex; r++) {
          const newRow = new wjcGrid.Row();
          newRow.visible = !row.isHidden;
          sheet.rows.push(new wjcGrid.Row());
        }
      }
    
      for (let j = 0; j < row.cells.length; j++) {
        const cell = row.cells[j];
        if (cell.e) {
          continue;
        }
        const colIdx = cell.c;
        const cellRange = self.getCellRange(sheet, row, cell);
        const sheetColumn = sheet.columns[colIdx];
    
        if (sheetColumn) {
          sheet.setCellData(rowIndex, colIdx, cell.v);
          self.mergeCell(sheet, cellRange, row, cell);
          self.flexSheetStyleManagementService.setCellStyle(sheet, cellRange, cell, this.worksheetPageModel);
          cellRange.worksheetPageModel = cell;
        } else {
          console.warn('Invalid column index', cell);
        }
      }
    
      try {
        sheet.autoSizeRow(rowIndex);
      } catch (err) {
        console.log('[Excel] ', err);
      }
    
      rowIndex++;
      if (rowIndex >= worksheetPageModel.rows.length) {
        // this.setProgressBar(0, false);shaon
        callback();
        return;
      }
      const progress = Math.round((rowIndex / worksheetPageModel.rows.length * 100));
      this.fuseSplashScreenService.updateProgressBar(rowIndex, worksheetPageModel.rows.length, 'Rendering Spreadsheet', true);
    }
    if (rowIndex < worksheetPageModel.rows.length) {
      console.log(rowIndex, '[Excel] cell row writen threadId' + threadId);
    
      requestAnimationFrame(()=> {
        self.writeToWorksheet(rowIndex, maxRowToWritePerCall, worksheetPageModel, sheet, callback, self, threadId);
      })
    }
    

    }

  • Posted 3 March 2023, 4:26 am EST

    Hi,

    As per our investigation, there is no need to do any custom merging of cells after importing files from Excel. The FlexSheet automatically adjusts the merging of cells while importing the sheet. Please share a sample replicating the issue because of which the above code is used or modify the following sample so that we can investigate further on this query.

    Please refer to this sample for reference: https://jscodemine.grapecity.com/share/_bjR9oX-ekWD-AeiwE5Afw/

    Excel file used in the process. Sample_file.zip

    Regards,

    Manish Gupta

  • Posted 3 March 2023, 6:55 pm EST - Updated 3 March 2023, 6:58 pm EST

    I have attached the excel file where it doesn’t work correctly , You can see that frozen columns are not working correctly here . I have other excel where they don’t load completely . i get error of –

    index.js:14 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'row')
        at _xlsx._getSharedFormula (index.js:14:100301)
        at _xlsx._getSheet (index.js:14:58928)
        at eval (index.js:14:39846)

    here is the excel Sample_file.zip

  • Posted 3 March 2023, 6:55 pm EST

    here is the excel

  • Posted 5 March 2023, 11:41 pm EST

    Hi,

    We are able to replicate the issue in frozenColumns on our end. However, there does not occur any such error shared in the screenshot. The problem is arising because the excel file consists of some hidden columns and the last frozen column encompasses the hidden columns. Due to this the count of frozenColumns is not set as expected.

    This issue has been reported to the concerned team with the internal tracking id WJM-26387. We will let you know as we have an update on this.

    Meanwhile, we may set the frozen columns after the sheets are loaded or the selected sheet is changed by calculating the hidden columns and deciding appropriate values for frozenColumns property.

    If there is any specific file having an issue with the FlexSheet import, please share the excel file.

    Also, for the merged cells, if half of the merged cell comes in the frozen column and half of it does not then, the text present in the frozen part of the cell will get ellipsed.

    If we want to remove the ellipse then we may set the text-overflow property for the cell to clip or if we want to set the text to overflow the merged cell then we may set the overflow property of the cell to be visible.

    The behavior of the merged cell in the above-described case will not match the behavior of Excel due to the difference in the formation of cells in FlexSheet and Excel.

    Please refer to this sample for reference: https://jscodemine.grapecity.com/share/2fD73rC-HE2Lw2jnyPJQRQ/

    Sample Excel file: Simple_custom_file.zip

    Hope it helps!

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels