We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Formatting a phone number does not work

Hello,

I have a spreadsheet which is formatting a 10 digit string as a phone number. Excel formats the value correctly but when I run this through Aspose.Cells it doesn’t format the phone number as expected.

Expected Results:
Input: 9999999999
Output: (999) 999-9999

Actual Results:
Input: 9999999999
Output: 9999999999

@randysimplist,
Please give a try to the following sample code and share the feedback.

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
var cells = worksheet.Cells;
var style = cells["A1"].GetStyle();
style.Custom = "[<=9999999]###\\-####;\\(###\\)\\ ###\\-####";
cells["A1"].SetStyle(style);
cells["A1"].Value = 9999999999;
workbook.Save("output.xlsx");

This sample code worked for me, thanks.

@lametcalef,
You are welcome.

Thank you, appreciate it. I did try to use the Formula command in Microsoft Word 2013 to add particular number formatting to cells in my table, similar to spreadsheet apps. You can also manually modify the appearance of your numbers using the most common formatting choices, the only problem was to get a verification message on my phone. After using this code, I came to the conclusion that something was wrong with my phone number. After trying a new phone number which I got from quackr.io, it did work finally.