0
我想在值超出Excel電子表格中單元格的閱讀,可能是格式2小數點前的數字值和DECMAL後2位數字時,Excel互操作
10.50
20.25
41.10
我正在使用Excel Interop來檢索值。
對於小於10的值,以下方法適用,但當值大於等於10時,值將被設置爲0.如何使用NumberFormat操作正確格式化此值?
double doubleHours = 0.0;
if (Extension.IsNumeric(excelWorksheet.Cells[rowCount, columnCount].Text))
{
Excel.Range range = excelWorksheet.Cells[rowCount, columnCount];
range.EntireColumn.NumberFormat = "#,##0.00";
double.TryParse(excelWorksheet.Cells[rowCount, columnCount].Text, out doubleHours);
//continue processing
}
'.Text'可以返回類似 「''####」 當值不適合,所以用'.Value.ToString()'代替 – Slai