docx

what is wrong with this binary file transfer (corrupting docx files)?

女生的网名这么多〃 提交于 2019-12-02 00:34:08
I've been trying to resolve this issue for over a week and could really do with some help. We are using a httprequest to post files to an api. Most files come out ok, but docx files end up corrupted. After much research I'm pretty sure that I'm doing something wrong in the binary post that is adding extra data / bytes to the file. Streams are being closed and I think I've got the boundries and headers right.... Are there any obvious mistakes in the code below? Or would anybody be able to point me in the right direction for a fix. Why is extra data being added to this file? Are http headers the

Retrieve document content with document structure with python-docx

≡放荡痞女 提交于 2019-12-02 00:14:49
I have to retrieve tables and previous/next paragraphs from docx file, but can't imagine how to obtain this with python-docx I can get a list of paragraphs by document.paragraphs I can get a list of tables by document.tables How can I get an ordered list of document elements like this [ Paragraph1, Paragraph2, Table1, Paragraph3, Table3, Paragraph4, ... ]? python-docx doesn't yet have API support for this; interestingly, the Microsoft Word API doesn't either. But you can work around this with the following code. Note that it's a bit brittle because it makes use of python-docx internals that

.NET Efficient way to generate WORD Doc - Server Side

烈酒焚心 提交于 2019-12-02 00:05:41
问题 .NET 4.0 I am looking for the easiest way to generate a Word document on our server. Limitations : Server side I don't want to install word on the server Data source is XML I tried to generate a DOCX with XSLT which is fast and easy but the only way I could find to validate the generated document is to open it with Word and the only error I get when the document is not valid is "Error while opening document". Not very useful. Any ideas? Thanks, Alex 回答1: You have two options given your setup.

Python docx library text align

…衆ロ難τιáo~ 提交于 2019-12-01 22:29:06
I am using python docx library to manipulate a word document. However I can't find how to align a line to the center in the documents page of that library. I can't find by google either. from docx import Document document = Document() p = document.add_paragraph('A plain paragraph having some ') p.add_run('bold').bold = True p.add_run(' and some ') p.add_run('italic.').italic = True How can I align the text in docx? Levent Altunöz With the new version of python-docx 0.7 https://github.com/python-openxml/python-docx/commit/158f2121bcd2c58b258dec1b83f8fef15316de19 Add feature #51: Paragraph

JavaScript library to read doc and docx on client

我们两清 提交于 2019-12-01 22:25:37
I am searching for a JavaScript library, which can read .doc - and .docx - files. The focus is only on the text content. I am not interested in pictures, formulas or other special structures in MS-Word file. It would be great if the library works with to JavaScript FileReader as shown in the code below. function readExcel(currfile) { var reader = new FileReader(); reader.onload = (function (_file) { return function (e) { //here should the magic happen }; })(currfile); reader.onabort = function (e) { alert('File read canceled'); }; reader.readAsBinaryString(currfile); } I searched through the

Open Microsoft Word docx file with Java

三世轮回 提交于 2019-12-01 22:24:16
How can I open a Microsoft Word docx file in Java? furthermore, how can I open it if it is password protected? For instance, File f = new File("hello.docx"); Please try to avoid responding with things such as "you shouldn't do this." I have a good reason for this, so please stick to the question when you answer. thanks a lot! There is Apache POI project for working with MS Office files. DOCX file is just a zip file with series of XML files inside, so you can unzip the file and work with XML. The XML spec (Open XML) is known. I haven't personally used it, but it looks like Apache POI will work

.NET Efficient way to generate WORD Doc - Server Side

ⅰ亾dé卋堺 提交于 2019-12-01 21:00:15
.NET 4.0 I am looking for the easiest way to generate a Word document on our server. Limitations : Server side I don't want to install word on the server Data source is XML I tried to generate a DOCX with XSLT which is fast and easy but the only way I could find to validate the generated document is to open it with Word and the only error I get when the document is not valid is "Error while opening document". Not very useful. Any ideas? Thanks, Alex You have two options given your setup. Use a third party library, something like the stuff available from SyncFusion Use the XML route, the

Python docx library text align

六眼飞鱼酱① 提交于 2019-12-01 20:22:28
问题 I am using python docx library to manipulate a word document. However I can't find how to align a line to the center in the documents page of that library. I can't find by google either. from docx import Document document = Document() p = document.add_paragraph('A plain paragraph having some ') p.add_run('bold').bold = True p.add_run(' and some ') p.add_run('italic.').italic = True How can I align the text in docx? 回答1: With the new version of python-docx 0.7 https://github.com/python-openxml

Update embedded excel file programmatically

久未见 提交于 2019-12-01 20:09:52
I'm trying to modify an embedded excel table in a word document programmatically. To do this, I have modified the docx file and the embedded excel file. The significant part of the main document is the following: <w:object w:dxaOrig="8406" w:dyaOrig="2056"> <v:shape id="_x0000_i1028" type="#_x0000_t75" style="width:390.75pt;height:95.25pt" o:ole=""><v:imagedata r:id="rId14" o:title=""/> </v:shape> <o:OLEObject Type="Embed" ProgID="Excel.Sheet.12" ShapeID="_x0000_i1028" DrawAspect="Content" ObjectID="_1349794876" r:id="rId15" UpdateMode="Always"/> </w:object> The word document uses an OLEObject

python-docx

蓝咒 提交于 2019-12-01 20:06:46
安装 pip install python-docx 简单示例,写入 from docx import Document word_file_1 = Document() word_file_1.add_paragraph('A plain paragraph') word_file_1.save('test.docx') 来源: https://www.cnblogs.com/python-abc/p/11715943.html