Skip to main content

Notifications

Announcements

No record found.

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. 

  • Fredrik Brandt Profile Picture
    Fredrik Brandt 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.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 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.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans