Exception: Create workbook from json

Posted by: diegoar27 on 24 October 2017, 6:05 am EST

  • Posted 24 October 2017, 6:05 am EST

    Hi!

    We are evaluating purchasing a license for Spread.Services and I’m testing it with the trial version.

    I’m creating a workbook from a json string and it’s throw me an exception: “Invalid color string: rgba(255, 255, 255, 0)

    I’m getting this json by GrapeCity.Spread.Sheets.ExcelIO.Importer and it’s working for spreadjs.sheet,

    I tried with many files and each work ok for spreadjs.sheet but I’m getting that exception every time that I do workbook.FromJson(…).

    Do you have any bug reported about that?

    Thanks in advance!

    Diego.

  • Posted 26 October 2017, 3:52 am EST

    Hi,

    This is correct, the color in Spread.Sheets is set as string in JS while for Spread.Services it is set as an object. I will further check the compatibility between two and let you know. Please allow me some time.

    Thanks,

    Deepak Sharma

  • Posted 26 October 2017, 10:21 pm EST

    Hi Diego,

    This issue is found to be a bug in Spread.Services and it will be fixed in our next service pack. The tracking id for same is #248262.

    Sorry for the inconvenience.

    Thanks,

    Deepak Sharma

  • Posted 1 November 2017, 9:14 am EST

    @deepak,

    1. When is the next service pack expected?
    2. How compatible is the Spread.Services with Spread.Sheets with respect to the json. From the documentation, spread.services should be able to load from the json created by spread.sheets and vice versa but it’s not working for a simple case. What’s the compatibility in terms of json, formulas, styling, etc.

    Please let us know as this will help us decide whether we should be using spread.services on the server or not.

  • Posted 2 November 2017, 1:50 am EST

    Hello,

    1. Service pack for Spread.Services is supposed to be released next month.
    2. I have asked the development team and they say that there no known issues with Spread.Sheets and Spread.Services compatibility. All the formulas and styles should work just fine. Please refer to the post:

      https://www.grapecity.com/en/forums/spread-services/spreadsheets-support

    Also the developer has suggested a workaround for the RGBA issue for the time being:

    He has given a code snippet that can replace all the string of rgba format with rgb format:

    string json = File.ReadAllText(@“C:\backColor.ssjson”);

    MatchCollection matches = Regex.Matches(json, @“rgba((\d+),\s*(\d+),\s*(\d+),\s*(\d+))”);

    foreach (Match match in matches)

    {

    string rgbStr = “rgb(” + match.Groups[1] + ", " + match.Groups[2] + ", " + match.Groups[3] + “)”;

    json = json.Replace(match.Value, rgbStr);

    }

            Workbook book = new Workbook();
            book.FromJson(json);
            book.Save(@"backColor.xlsx");
    

    You can remove the code once we release the service pack with the fix.

    Thanks,

    Deepak Sharma

  • Posted 2 November 2017, 8:14 am EST

    Hi @deepak,

    Thanks for your answer,

    after replace all the string of rgba format with rgb format I loaded a workbook from json ok but I found some differences on the styles that I had on the document before such as:

    1- Different column size.

    2- Different vAlign, now it’s 2 and It was 0.

    3- I lost my default font style, It was “font”: “14px Arial” and now It’s “font”: “normal normal 10pt Arial,sans-serif”.

    4- A new column added after open a workbook from json and convert the workbook to json.

    I attached both json strings.

    The originalDocFromSpreadsheets.json it’s the file that I create using spread.sheets and testSpreadServices.json It’s the file that I got after made workbook.toJson().

    If you open both files on spread.sheets you will see all differences that I’m mentioning.

    Thanks in advance.

  • Posted 2 November 2017, 11:46 pm EST

    Sorry here are the files TestFiles.zip

  • Posted 6 November 2017, 2:46 am EST

    Hi Diego,

    I have replied to forum post here:

    https://www.grapecity.com/en/forums/spread-services/differences-between-spread

    Thanks,

    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels