gpt4 book ai didi

.net - 打开 xml sdk 电子表格检查合并的单元格

转载 作者:行者123 更新时间:2023-12-04 00:44:51 27 4
gpt4 key购买 nike

如何检查单元格是否处于合并状态?

------------------------------------------------------------
Main Heading 1 | Main heading 2 |
------------------------------------------------------------
Sub Head 1 | sub head 2 | sub head 3 |
-------------------------------------------------------------
| | |

最佳答案

const string testFileName = @"C:\Users\koo\Desktop\test\test\Test.xlsx";
string sheetName = "Sheet1";
using (SpreadsheetDocument document = SpreadsheetDocument.Open(testFileName, true))
{
WorkbookPart wbPart = document.WorkbookPart;
Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetName).FirstOrDefault();
WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id));
MergeCells mcs = wsPart.Worksheet.Descendants<MergeCells>().First();

var mcl = mcs.ChildElements.ToList();
foreach (MergeCell mc in mcl)
{

}
document.WorkbookPart.Workbook.Save();
}

关于.net - 打开 xml sdk 电子表格检查合并的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12533932/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com