# Loss of Precision from Model Class to Excel Worksheet

• ### Question

• I suspect I am not using the tableOptions syntax properly. Decimals out to 15 digits are being truncated. I note that in the excel manual custom format precision appears to be available out to 14 digits.

Any clues appreciated , I also need to set column width to the amount necessary to show the digits. I admit 15 digits are a lot. This is interest rate data. Thanks for any assistance.

//write the TableData to Excel
function setExcelData(officeTable) {
if (officeTable != null) {
Office.context.document.setSelectedDataAsync(officeTable, { coercionType: Office.CoercionType.Table , tableOptions:  {numberFormat: "##.###############"}} , function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
}
else {
}
});
}
}

Doyle

Monday, April 6, 2015 5:18 PM

• Hi Doyle,

>>Decimals out to 15 digits are being truncated

15 digits is the maximum limit, you could refer the link below for moreinformation:
#Excel specifications and limits

>> Loss of Precision from Model Class to Excel Worksheet

What do you mean by “Loss of Precision”? Do you mean that you want to set the value with 15 digits, but it did not work when the digit of the value was less than 15, like when you format “15.123”, you got the value of “15.123” instead of “15.123000000000000”? If so, I am afraid that the value of the numberFormat was wrong. You need to set the numberFormat as “##.000000000000000”. The “0” digit placeholder displays insignificant zeros if a number has fewer digits than there are zeros in the format. However, Excel does not display extra zeros when the number that you type has fewer digits on either side of the decimal than there are # symbols in the format. The link below shows more details:

>> I also need to set column width to the amount necessary to show the digits

# How to: Format tables in apps for Excel
https://msdn.microsoft.com/en-us/library/office/dn535872.aspx?f=255&MSPPError=-2147217396

In addition, since the original issue is about the Loss of presicion, if you still have any issue about setting column width. I will recommend you post a new thread for the second issue.

The reason why I suggested is:

#1 There would be more community members to discuss the question.
#2 For people who have the similar question, it would be easier for them to find the answer from a specific thread.