web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Format a column in Excel worksheet to Text

(0) ShareShare
ReportReport
Posted on by 15

Hi,
How can I format my Excel workbook to have the column as Text?

If I pass this field (defined as a string):

xlsWorkSheet.cells().item(1,4).value(custTable.VATNum);

It will be regarded as an integer.

I have in my field in column D a string (say "0001").

When Excel creates the column it interprets the string as number and removes the leading "000" and will convert it to integer.

I don't want that and the text should remain.

Can I use this below in some way?

xlsWorkSheet.cells().range('D:D').?

Any idéas?

Regards,

/Fredrik. 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Fredrik Brandt,

    Check whether the below Microsoft documentation will help your scenario.

    https://learn.microsoft.com/en-us/office/vba/api/excel.range.numberformat

    Thanks,

    Girish S.

  • Fredrik Brandt Profile Picture
    15 on at

    Hi again,

    I found it.

       //Format column D to Text in the worksheet - @ means data stored in excel as string

       xlsWorkSheet.cells().range('D:D').numberFormat('@');

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans