如何使用OpenXML库和C#在Excel文档中获取当前选定的单元格或范围

时间:2016-08-09 06:56:10

标签: c# excel-2007 openxml

我正在尝试获取当前选定的单元格或单元格区域以更改或编辑值或样式,但我不喜欢使用 Interop 库。

2 个答案:

答案 0 :(得分:0)

选择不会保存在xlsx中。我已经保存了2个空白工作簿,具有不同的选择,然后递归地比较两个zip包的提取文件内容。唯一不同的是dcterms:modified中的docProps\core.xml节点。

答案 1 :(得分:0)

在每张表中,

SheetView元素具有活动单元格,如此

function testFunction(refreshFrequ){
    setTimeout(function() {
        console.log("frequency: "+refreshFrequ);
        testFunction(refreshFrequ);
    }, refreshFrequ);
}

// run the 1st time
testFunction(5000);

获取此功能的OpenXML类是 https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.selection.activecell(v=office.14).aspx