采用OpenXML的C#中获取Excel单元格的列索引 [英] Get the Column Index of a Cell in Excel using OpenXML C#

查看:747
本文介绍了采用OpenXML的C#中获取Excel单元格的列索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在东张西望了一会儿,似乎无法找出如何做到这一点。
我有一个Excel工作表,其中我使用的OpenXML阅读。现在正常的事情是通过行循环,然后遍历细胞得到的值,这是罚款。但与值一起我需要的细胞,这将是在格式(rowIndex位置,参数:columnIndex)的位置。我已经设法获得的rowIndex,但不能似乎找出获取列索引。

I've been looking around for a while now and cannot seem to find out how to do this. I've got an excel sheet, which I'm reading using OpenXML. Now the normal thing would be to loop through the rows and then loop through the cells to get the values, which is fine. But along with the values I need the location of the cell, which would be in the format (rowindex, ColumnIndex). I've managed to get the rowIndex, but cant seem to figure out getting the column Index.

其实我认为这是一件容易的事,但显然它不是。

I actually thought this was going to be easy but apparently it isnt.

推荐答案

既然你可以通过使用一排的细胞循环 Worksheet.Descendants<电池>() ,你可以简单地使用 -loop确定单元格的索引。

Since you can loop through the cells of a row using Worksheet.Descendants<Cell>(), you can simply use a for-loop to determine the index of the cell.

这篇关于采用OpenXML的C#中获取Excel单元格的列索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆