POI to SpreadJS JSON conversion and vice versa

Posted by: datta on 21 May 2019, 11:46 pm EST

  • Posted 21 May 2019, 11:46 pm EST

    This is more of a feature request for SpreadJS to consider. It would be grate if you can provide a java library for converting POI Workbook to SpreadJS JSON and vice versa. This will be very useful for Java applications which want to modify workbook by converting json to POI workbook . Request you to please consider it

  • Posted 22 May 2019, 8:38 pm EST

    Hi,

    We have created a feature request on your behalf(Internal tracking id #272791) to support this feature. We will let you know about any updates regarding the same.

    Regards

  • Posted 23 June 2019, 10:36 pm EST

    Hi,

    DevTeam has reviewed the feature request and have suggested to use the ‘document for excel’(https://www.grapecity.com/documents-api-excel-java)

    Please refer to the following code snippet which demonstrates how we could use documnets for excel to convert apache poi workbook to spread json:

    private static void ConvertPOIToSSJSON() throws IOException {
            try (Workbook wb = new XSSFWorkbook()) { //or new HSSFWorkbook();
                Sheet sheet = wb.createSheet("new sheet");
    
                // Create a row and put some cells in it. Rows are 0 based.
                Row row = sheet.createRow(1);
    
                Cell cell0 = row.createCell(0);
                cell0.setCellValue(1);
    
                // Or do it on one line.
                row.createCell(1).setCellValue(1.2);
                row.createCell(2).setCellValue("This is a string");
                row.createCell(3).setCellValue(true);
    
                // Aqua background
                CellStyle style = wb.createCellStyle();
                style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
                style.setFillPattern(FillPatternType.BIG_SPOTS);
                Cell cell = row.createCell(1);
                cell.setCellValue("X");
                cell.setCellStyle(style);
    
                // Orange "foreground", foreground being the fill foreground not the font color.
                style = wb.createCellStyle();
                style.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
                style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                cell = row.createCell(2);
                cell.setCellValue("X");
                cell.setCellStyle(style);
    
                // Write the output to a file
                try (ByteArrayOutputStream poiOutputStream = new ByteArrayOutputStream()) {
                    wb.write(poiOutputStream);
    
                    ByteArrayInputStream inputStream = new ByteArrayInputStream(poiOutputStream.toByteArray());
                    com.grapecity.documents.excel.Workbook workbook = new com.grapecity.documents.excel.Workbook();
                    workbook.open(inputStream);
                    String jsonString = workbook.toJson();
    
                    workbook.save("gcexcel.xlsx");
                }
            }
        }
    

    Regards

  • Posted 17 July 2019, 10:09 pm EST

    Hi is same license applicable for both SpreadJS and documents api? We have bought license for SpreadJS . Can I use same license to use documents java api?

  • Posted 18 July 2019, 2:29 pm EST

    Hi,

    You would need to purchase a separate license for Documents API. I would also suggest you to contact our Sales Team for further details. Contact details are shared below

    Email:us.sales@grapecity.com

    Phone: 1.800.858.2739 | 412.681.4343

Need extra support?

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

Learn More

Forum Channels