作者lazybones (懒)
看板C_Sharp
标题Re: [问题] 取得Excel的所有sheet
时间Mon Jun 29 23:55:16 2009
不好意思,又有问题想请教一下
我要如何去取得目前使用中的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
1F:推 Catbert:excelWorksheet.UsedRange.Columns.Count 06/30 00:03
2F:→ lazybones:谢谢!! 06/30 00:52
3F:→ lazybones:再请教一下 若是要取得某row的column数 要用什麽? 06/30 11:23
※ 编辑: lazybones 来自: 210.69.124.17 (06/30 15:59)
4F:推 holybible:假设row I => Range.rows[i].columns.count 07/06 00:24