开发者

Set Number format in excel using interop

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜