看板 C_Sharp 關於我們 聯絡資訊
不好意思,又有問題想請教一下 我要如何去取得目前使用中的sheet的column和row的數目? 下面是我的code,不過取出來的columns.count都是256 謝謝 public string[] GetSheetHeader() { string[] header = new string[excelWorksheet.Columns.Count]; Excel.Range oRange = null; int i = 0; if (this.excelSheets != null) { for (i = 0; i < excelWorksheet.Columns.Count; i++) { oRange = excelApp.get_Range(excelApp.Cells[1, i + 1], excelApp.Cells[1, i + 1]); header[i] = oRange.Value2.ToString(); } } return header; } -- ╔╮ ╭═╦╮╭═╦╗╮ ╮╔══╮╭═╦╮╮ ╔╮╔══╮╭══╮ ╠╣ ╠═╬╣╭╬╩╯╰╦╦╯╠═╦╮║ ╠╣║║╠╣╠╣ ╰═╦╮ ╠╣ ╭║ ╠╣║╰╔╗ ╠╣ ║ ╠╣║ ╠╣║╰╠╣║╰╔╗║ ╠╣ ╰╩═╯╰ ╰╝╚═╩╯ ╰╝ ╚═╩╯╰═╩╯╰ ╰╝╚═╩╯╰═╩╯ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.20.144.252
Catbert:excelWorksheet.UsedRange.Columns.Count 06/30 00:03
lazybones:謝謝!! 06/30 00:52
lazybones:再請教一下 若是要取得某row的column數 要用什麼? 06/30 11:23
※ 編輯: lazybones 來自: 210.69.124.17 (06/30 15:59)
holybible:假設row I => Range.rows[i].columns.count 07/06 00:24