Graph API workbook - update range - US setting of number format

341 Views Asked by At

I'm using Microsoft Graph API to update values in a excel sheet. Number format for the given cells is also specified. Number format is custom format for money. Format is taken from excel.

Sample: $ 10,740,081 - US dollar without decimals

The excel file is placed on the SharePoint with non US language setting.

My code is:

private const string MoneyFormat = "_($* #,##0_);_($* (#,##0);_($* \"-\"??_);_(@_)";
...
WorkbookSessionInfo sessionInfo = await client.Sites["{siteId}"].Drives["{driveId}"].Items["{fileId}"].Workbook.CreateSession(true).Request().PostAsync();

var workbookRange = new WorkbookRange
{
   Values = JToken.FromObject(values), // [["10", "100"]]
   Formulas = JToken.FromObject(formulas), // [[null, null]]
   NumberFormat = JToken.FromObject(numberFormat) // [[MoneyFormat, MoneyFormat]]
};

var worksheetRangeRequest = client.Sites["{siteId}"].Drives["{driveId}"].Items["{fileId}"].Workbook.Worksheets["{sheetName}"].Range("A1:B1").Request();
AddWorkbookSessionIdHeader(worksheetRangeRequest, sessionInfo.Id);
await worksheetRangeRequest.PatchAsync(workbookRange);

var closeRequest = client.Sites["{siteId}"].Drives["{driveId}"].Items["{fileId}"].Workbook.CloseSession().Request();
AddWorkbookSessionIdHeader(closeRequest, sessionInfo.Id);
await closeRequest.PostAsync();

If I open the result excel file the specified number format is almost correct except for the currency symbol. The currency symbol $ is ignored and it shows the currency symbol related to my local setting.

If I check the detail of the number format applied to the cell, the format is a little bit different

_(Kč* # ##0_);_(Kč* (# ##0);_(Kč* "-"??_);_(@_)

Is there any way how can I enforce Graph API to use the specified currency symbol?

0

There are 0 best solutions below