Get the Column Index of a Cell in Excel using OpenXML C#

前端 未结 8 1827
北恋
北恋 2020-12-03 17:32

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

8条回答
  •  眼角桃花
    2020-12-03 18:10

        Row row = worksheetPart.Worksheet.GetFirstChild().Elements().FirstOrDefault();
       var totalnumberOfColumns = 0;
        if (row != null)
            {
                var spans = row.Spans != null ? row.Spans.InnerText : "";
                    if (spans != String.Empty)
                            {
                                //spans.Split(':')[1];
                                string[] columns = spans.Split(':');
                                startcolumnInuse = int.Parse(columns[0]);
                                endColumnInUse = int.Parse(columns[1]);
                                totalnumberOfColumns = int.Parse(columns[1]);
                            }
            }
    

    this is to find the total number of columns present/used

提交回复
热议问题