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.
精彩评论