C#,Visual Studio 2010中C#訪問EXCEL,格式化單元作爲通用
當Excel細胞在C#(經由COM對象)操縱,我應該使用。價值或.Value2? 是
sheet.Cells[row + n, col].Value = "Hello world"
或
sheet.Cells[row + n, col].Value2 = "Hello world"
是什麼它們之間的區別?
另外,如何設置單元格格式爲「常規」?
sheet.Cells[row + n, col].NumberFormat = "XYZ"; // Not sure what should be here
現在,當我分配一個小區甚至如果我做
sheet.Cells[row + n, col].NumberFormat = "@";
我得到這個「小錯誤」,數字「0.34」,並在每個單元中的左上角註冊
感謝您的文章,我現在看到的差異,如果我使用「一般」,我得到的錯誤「屬性NumberFormat不能用於類的範圍」 –