web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,825 Moderator on at
    RE: Format a column in Excel worksheet to Text

    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
    RE: Format a column in Excel worksheet to Text

    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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans