Replaced Far Point with gc documents for Spread JS 13

Posted by: pooja.bansal on 19 January 2021, 2:39 am EST

  • Posted 19 January 2021, 2:39 am EST

    In our application, previously we were using Farpoint Excel.IO to convert Spread.Net instance to Spread Js instance. Now, we have replaced Farpoint with gc documents for Spread JS 13.

    After updating to gc documents we are facing following issues -

    1. Extra empty columns and rows are appearing in the Spread.

      Q 1) How can we calculate MaxRowCount and MaxColColumn count corresponding to the data?

    2. Unable to add new new row in a a spread.

      Q2) How can we add new row in spread js 13?

    3. Hidden rows are not working.

      Q3) How can we hide rows corresponding to some logic?

    4. Unable to see graphic data (Charts) on spread initial load

      Q4) How can we show the graphic data on spread load?

    5. Save to file not working in template with charts/graphics.

      Q5) How can we export templates containing graphics/charts?

    6. Grouping is not working.

      Q6) How can we enable and make grouping working in Spread?

    Regards

    Pooja Bansal

  • Posted 20 January 2021, 8:41 am EST

    Hi Pooja,

    Q1)How can we calculate MaxRowCount and MaxColColumn count corresponding to the data?



    There is no direct method available for the required functionality but you may use toJSON method and create your function which provide the last nonempty rows and column. Please refer to the following code snippet and attached sample that demonstrates the same.

    
    function _getLastNonEmptyRow(sheet) {
      let rows = Object.keys(sheet.toJSON().data.dataTable);
      //the largest Row index is available at the last of the array
      return 1 + +rows[rows.length - 1];
    }
    function _getLastNonEmptyCol(sheet) {
      let json = sheet.toJSON();
      let dataTable = Object.keys(json.data.dataTable);
      let nonEmptyColIndex = -1;
      dataTable.forEach((row) => {
        let rowArray = Object.keys(json.data.dataTable[row]);
        rowArray.forEach((col) => {
          nonEmptyColIndex = Math.max(nonEmptyColIndex, col);
        });
      });
    
    

    sample:https://codesandbox.io/s/spreadjs-custom-formula-reference-forked-q1ms9?file=/src/index.js:634-1172

    Q2) How can we add new row in spread js 13?

    You may use addRows method for the required functionality. Please refer to the following snippet.

    
    activesheet.addRows(rowIndex, noOfRowTobeAdded)
    
    

    addRows:https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~addRows.html

    Q3) How can we hide rows corresponding to some logic?

    You may use setRowVisble method for the required functionality. Please refer to the following code snippet.

    
    sheet.setRowVisible(index,false)
    
    

    setRowVisible: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~setRowVisible.html

    Q4) How can we show the graphic data on spread load?

    You may use sheet.charts.add() method for the required functionality. Also, make sure you import the charts library before using the charts methods. Please refer to the following code snippet.

    
        sheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 0, 100, 400, 300, "A1:D4");
    
    

    ChartsDemo: https://www.grapecity.com/spreadjs/demos/features/charts/basic-chart/purejs

    How can we export templates containing graphics/charts?

    you may use excelIO for exporting the sheet. Please refer to the following code snippet and attached demo.

    
     //import excel file to SpreadJS json
        excelIo.open(excelFile, function (json) {
            var workbookObj = json;
            workbook.fromJSON(workbookObj);
        }, function (e) {
            // process error
            console.log(e);
        });
        //export SpreadJS json to excel file
        excelio.save(json, function (blob) {
            //do whatever you want with blob
            //such as you can save it
        }, function (e) {
            //process error
            console.log(e);
        });
    
    

    importExportDemo: https://www.grapecity.com/spreadjs/demos/features/workbook/excel-import-export/purejs

    How can we enable and make grouping working in Spread?

    You may use out line feature for the required functionality. Please refer to the following code snippet and demo that demonstrate the same.

    
    var sheet = spread.getActiveSheet();
        sheet.rowOutlines.group(1, 10);
        sheet.columnOutlines.group(1, 5);
    
    

    Grouping Demo: https://www.grapecity.com/spreadjs/demos/features/worksheet/outline/basic-group/purejs

    Regards

    Avinash

  • Posted 21 January 2021, 12:23 am EST

    Hi,

    For getting the column count we are using below method -

    GrapeCity.Documents.Excel.Workbook.Worksheets[sheetNo].Columns.ColumnCount

    What would be the method to set the row and column count using above code in c# ?

    Regards

    Pooja Bansal

  • Posted 21 January 2021, 9:00 am EST

    Hi Pooja,

    You may use setRowCount and setColumnCount method for the required functionality. Please refer to the following code snippet and let us know if you face any issues.

    
    sheet.setRowCount(100);
    sheet.setColumnCount(20)
    
    

    setRowCount: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~setRowCount.html

    setColumnCount: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~setColumnCount.html

    Regards

    Avinash

  • Posted 29 January 2021, 10:28 am EST

    Hi,

    I have created a new enhancement request for GcExcel to add support for RowCount and ColumnCount in the exported SSJSON for SpreadJS. We can add the feature to make it easy to get and set the row and column counts of the worksheet, which will only take effect when saving SSJSON. This enhancement will be scheduled for the 4.2 release.

    Regards,

    Sean Lawyer

    GrapeCity Documents Team

Need extra support?

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

Learn More

Forum Channels