簡體   English   中英

如何使用OpenXML庫和C#獲取Excel文檔中當前選定的單元格或范圍

[英]How to get currently selected cell or range in Excel document using OpenXML library and C#

我試圖獲取當前選擇的單元格或單元格范圍以更改或編輯值或樣式,但是我不喜歡使用Interop庫。

選擇不會保存在xlsx中。 我已經保存了2張空白的工作簿,它們具有不同的選擇,然后遞歸比較兩個zip包的提取文件內容。 唯一的區別是docProps\\core.xml dcterms:modified節點。

在每張紙上

SheetView元素具有活動單元格,如下所示

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
  <dimension ref="A1:B8"/>
  <sheetViews>
    <sheetView tabSelected="1" workbookViewId="0">
      <selection activeCell="A2" sqref="A2:B3"/>
    </sheetView>
  </sheetViews>

使您滿意的OpenXML類是https://msdn.microsoft.com/zh-cn/library/documentformat.openxml.spreadsheet.selection.activecell(v=office.14).aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM