积极答复者
C#自动化Excel中UsedRange.Rows.Count的问题

问题
答案
-
你好
我做了下面测试代码,但是没遇到你说的那种情况。我猜你是不是删除之后没有保存excel呢?
希望对你有帮助。public Form1() { InitializeComponent(); object missing = Missing.Value; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); xlApp.Workbooks.Open(@"d:\test3.xlsx", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlApp.Workbooks[1].Worksheets[1]; MessageBox.Show(ws.UsedRange.Rows.Count.ToString()); xlApp.Quit(); }
Cookie Luo[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Cookie Luo 2011年4月13日 9:15
全部回复
-
你好
我做了下面测试代码,但是没遇到你说的那种情况。我猜你是不是删除之后没有保存excel呢?
希望对你有帮助。public Form1() { InitializeComponent(); object missing = Missing.Value; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); xlApp.Workbooks.Open(@"d:\test3.xlsx", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlApp.Workbooks[1].Worksheets[1]; MessageBox.Show(ws.UsedRange.Rows.Count.ToString()); xlApp.Quit(); }
Cookie Luo[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Cookie Luo 2011年4月13日 9:15
-
你好
我关闭这个帖子,如果还有问题的话,点击取消标记为答复。
Cookie Luo[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.