C1Excel Format column as string

Posted by: arno_hendrikx on 18 December 2018, 7:36 am EST

    • Post Options:
    • Link

    Posted 18 December 2018, 7:36 am EST

    Hi,

    On creating and Excel Book you can set various formats for numbers, dates etc. But I need to format a whole column as being TEXT; meaning when you open the xls and enter 01234 in there, it remains 01234 instead of 1234. Like the ’ operator you use to identify it in Excel as being TEXT.

    Looked everywhere in documentation and samples, but did not find any.

    Anyone has an idea?

    Thanks,

    Arno

  • Posted 19 December 2018, 6:08 am EST

    Hi Arno!

    You can apply formatting to individual cells instead of the column, where XLStyle instance can be defined like this:

    XLSheet sheet = c1XLBook1.Sheets[0];
    XLStyle st = new XLStyle(c1XLBook1);
    st.Format = "@";
    
    //For all the cells in a column
    sheet[*row*, *column*].Style = st;
    

    This sets Format of all these cells to Text in the saved Excel file.

    Regards,

    Meenakshi

  • Posted 19 December 2018, 7:40 am EST

    Thanks Meenakshi!

    That did the trick!!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels