Numeric format lost on import

3 posts, 0 answers
  1. Michael
    Michael avatar
    6 posts
    Member since:
    Dec 2012

    Posted 13 May Link to this post

    I'm generating spreadsheets server-side, and with the Kendo spreadsheet now available, would like to make those visible in the browser rather than having the client download the file. The spreadsheets are being created by the open source EPPlus library. I'm not having difficulty showing the spreadsheet, but it's displaying incorrectly.

    When doing a server-side import, the number formatting in the cells is lost during the ToJson call back to the client. This can be seen in the Server Import/Export Demo as well. The correct numeric values are present, but their display is wrong. 

    I'm sending the data back to the server with

    public ActionResult GetSpreadsheet(string fname)
    {
       Stream stream = ReportsController.GetStreamFromCache(fname);
     
       if (stream != null)
       {
          Workbook workbook = Workbook.Load(stream, Path.GetExtension(fname));
          return Content(workbook.ToJson(), MimeTypes.JSON);
       }
     
       return new EmptyResult();
    }

    I've attached a spreadsheet that is showing the problem. It displays correctly in Excel on opening.Oddly enough, I haven't seen anyone mention this on the forums, so I'm wondering if it's something with my spreadsheets.Ideally, I'd use the Workbook object on the server to create the spreadsheets, but we have entirely too many already written to convert.

    Thanks for any help you can give.

     

  2. Michael
    Michael avatar
    6 posts
    Member since:
    Dec 2012

    Posted 13 May in reply to Michael Link to this post

    A little more info -- generating a PDF from this spreadsheet works perfectly, so I don't believe it's the spreadsheet.

    public ActionResult PDF(string fname)
    {
       Stream dataStream = ReportsController.GetStreamFromCache(fname);
     
       if (dataStream != null)
       {
          Workbook workbook = Workbook.Load(dataStream, Path.GetExtension(fname));
          Telerik.Windows.Documents.Spreadsheet.Model.Workbook document = workbook.ToDocument();
     
          using (MemoryStream outputStream = new MemoryStream())
          {
             PdfFormatProvider provider = new PdfFormatProvider();
             provider.Export(document, outputStream);
     
             return File(outputStream.ToArray(), MimeTypes.PDF, $"{Path.GetFileName(fname)}.pdf");
          }
       }
     
       return new EmptyResult();
    }

     

  3. Kendo UI is VS 2017 Ready
  4. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 17 May Link to this post

    Hello Michael,

    Thank you for the excel file -- we have reproduced the issue on our side and it has been logged for investigation.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top