解码由Excel生成的剪贴板的XML电子表格内容

我想在我的程序中做一个非常简单的事情:

当用户在Excel(2007 – 2016)中做出select副本时,我希望能够读取剪贴板内容,然后提取所有值。

目前,Excel会在剪贴板中放入不同的格式,如Biff5,Biff8,CSV,纯文本等。

一个简单的解决scheme可能是使用CSV格式,但这不够精确,因为如果我在数字上滚动,我不知道它是否是string或Excel文件中的数字。 date也是以原始格式发送的,理解它会是一件痛苦的事情。

所以我看到的解决scheme是parsingExcel发送的“XML Spreadsheet”,看起来像这样:

<?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Feuil1"> <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="3" ss:DefaultColumnWidth="60" ss:DefaultRowHeight="15"> <Row> <Cell><Data ss:Type="Number">8</Data></Cell> </Row> <Row> <Cell><Data ss:Type="Number">9</Data></Cell> </Row> <Row> <Cell ss:Formula="=SUM(R[-2]C:R[-1]C)"><Data ss:Type="Number">17</Data></Cell> </Row> </Table> </Worksheet> </Workbook> 

在你问之前,我已经考虑过POI。 但据我所知,我需要使用XSSF。 但要使用,我需要poi-ooxml,并使用,我需要poi-ooxml-schemas和poi。 我不知道这些JAR的总重量,但我并不热衷于添加10Mb的JAR来提取剪贴板上的信息。

有没有人试过这样做? 有没有一个项目可以做到这一点?

解决问题的代码可以在这里find:

https://github.com/Maxoudela/XMLSpreadsheetParser