开发者

Set Number format in excel using interop

开发者 https://www.devze.com 2023-03-21 16:29 出处:网络
Using the method below I can load a row at time into an Excel file.Once all the rows are loaded into Excel.

Using the method below I can load a row at time into an Excel file. Once all the rows are loaded into Excel.

A column holds alphanumeric characters,if cell content is numbers its aligned to left side otherwise aligned to right side.I need to always aligned to right side.

I would like change the format 开发者_开发技巧of cell to Text.

  private void AddExcelRows(string startRange, int rowCount,int colCount, object values)
    {
        _range = _sheet.get_Range(startRange, _optionalValue);
        _range = _range.get_Resize(rowCount, colCount);
        _range.set_Value(_optionalValue, values);
    }

How can I set cell format as Text?


The text format is the '@' symbol, so:

_range.NumberFormat = "@";

should do the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消