我如何使用行数和列数在VSTO / C#得到一个Excel范围? [英] How do I get an Excel range using row and column numbers in VSTO / C#?
本文介绍了我如何使用行数和列数在VSTO / C#得到一个Excel范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得这个问题概括起来。鉴于行和列两个整数或者四个整数的行和列的一系列的两个角落,我该如何获取该范围内的范围对象。
I think the question sums it up. Given two integers for row and column or four integers for row and column for the two corners of a range, how do I get a range object for that range.
推荐答案
凡范围是多个单元格:
Excel.Worksheet sheet = workbook.ActiveSheet;
Excel.Range rng = (Excel.Range) sheet.get_Range(sheet.Cells[1, 1], sheet.Cells[3,3]);
在哪里范围为一个单元格:
Where range is one cell:
Excel.Worksheet sheet = workbook.ActiveSheet;
Excel.Range rng = (Excel.Range) sheet.Cells[1, 1];
这篇关于我如何使用行数和列数在VSTO / C#得到一个Excel范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文