English 中文(简体)
(OpenXML) Add data pages to xml package without framework
原标题:

lately I ve been into combining multiple OpenXML speadsheets via PHPExcel which showed me that this framework has certain issues which makes it pretty much unusable for what I want to do (my related SO question).

To make it short: it s hard to guarantee that all formatting features of Excel 2007 will persist a file merge performed with that particular framework.

Anways, now I m thinking of a more general approach. I want to open a template XLSX which contains various formatting and add some plain alphanumeric data worksheets at the end of the workbook.

Is sensefully possible to do the following:

  • unzip template XLSX
  • parse XML files
  • add worksheets
  • save xml files
  • rezip files to get valuid XLSX

Any hints or experiences would be highly appreciated.

thanks in advance

K

问题回答

I haven t worked with .xlsx too much, but I ve altered .docx files by manually adding and editing the XML.

The biggest concern with adding new parts to a document is to make sure you update the .rels files. The best way to figure out what needs to be updated is to create a new .xlsx document in Excel, add a worksheet, save the file and then unzip it to see what has changed. You can also use the DocumentReflector tool that comes with the OpenXML SDK if you want to see the internals of the file without having to unzip it.

I found the OpenXML reference manual very helpful when hand editing files because it tells you what elements you have to keep and what elements are optional to make a valid document. It makes it easier to work with when you can remove some of the extraneous elements that Excel adds automatically.





相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Is it exists any "rss hosting" with API for creating feeds

I am creating a desktop app that will create some reports. I want to export these reports as RSS or ATOM feeds. I can easily create feeds with Rome lib for Java. But I have no idea how to spread them. ...

Improving Q-Learning

I am currently using Q-Learning to try to teach a bot how to move in a room filled with walls/obstacles. It must start in any place in the room and get to the goal state(this might be, to the tile ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

Def, Void, Function?

Recently, I ve been learning different programming langages, and come across many different names to initalize a function construct. For instance, ruby and python use the def keyword, and php and ...

热门标签