admin管理员组

文章数量:1336331

I have an application that needs to create simple OpenXML documents (in particular PowerPoint presentations) using JavaScript.

Can anyone suggest how to get started on this please (or even if it is possible)? I've used the Microsoft OpenXML SDK for doing something similar using C#, and was wondering whether there were any JavaScript libraries with similar functionality.

Essentially the problem is how to create the individual OpenXML documents that make up an unzipped PowerPoint document, then zip them together to create the PowerPoint (.pptx) file, which someone can then save to their disk.

Any ideas wele!

I have an application that needs to create simple OpenXML documents (in particular PowerPoint presentations) using JavaScript.

Can anyone suggest how to get started on this please (or even if it is possible)? I've used the Microsoft OpenXML SDK for doing something similar using C#, and was wondering whether there were any JavaScript libraries with similar functionality.

Essentially the problem is how to create the individual OpenXML documents that make up an unzipped PowerPoint document, then zip them together to create the PowerPoint (.pptx) file, which someone can then save to their disk.

Any ideas wele!

Share Improve this question asked Nov 30, 2011 at 16:38 AppetereAppetere 6,2818 gold badges39 silver badges49 bronze badges 5
  • 2 Why do you need to do it client-side? It's almost impossible and very unfortable, while doing it server-side is a breeze in almost any language. – Viruzzo Commented Nov 30, 2011 at 16:41
  • I agree with Viruzzo, you should consider implementing it server-side. If it's acceptable, you can publish it as a web service and call its methods from java script by using AJAX calls. – Lukasz M Commented Nov 30, 2011 at 16:46
  • Yes I agree that doing it client-side would be much easier (& is what I did on a previous project). But in this case the client wants something that will run stand-alone and with cross-browser patibility. – Appetere Commented Nov 30, 2011 at 17:08
  • for great cross-browser patibility, implement it server-side. What does your client mean by "stand-alone", in this case? – Michael Paulukonis Commented Nov 30, 2011 at 18:09
  • 1 Maybe you can try to manually create an empty OpenXML file (i.e. an empty pptx) as a base template and then try to work on it as an XML with java script code. It could be much easier than creating the file with java script, however, it still seems like a lot of work to do. – Lukasz M Commented Nov 30, 2011 at 18:23
Add a ment  | 

3 Answers 3

Reset to default 4

Use the OpenXML SDK for Javascript

Obviously, operations such as Zipping/unZipping a document or saving a document cannot be done client-side and with pure javascript.

However, if you want to do such things, I do believe that there are Linux packages out there that accept strings as input and give you a ready to use Office document as output.

If you're not convenient with Linux packages, assuming you want to save this as a word 2007 document:

<?xml version="1.0" encoding="utf-8"?> 
<w:document xmlns:w="http://schemas.openxmlformats/wordprocessingml/2006/main"> 
    <w:body> 
        <w:p> 
            <w:pPr> 
            <w:pStyle w:val="MyHeading1" /> 
            </w:pPr> 
            <w:r> 
            <w:t>This is Heading</w:t> 
            </w:r> 
        </w:p> 
    </w:body> 
</w:document>

You can build this string, client-side. then send it to server through AJAX and let your server deal with it. specifically I have used these APIs myself multiple times. let PHP handle it. save the result somewhere, or force client's browser to download it (stream results)

USE OPEN XML SDK. You can run it on node and in 32 seconds it creates 2000 documents. Or you can run it on the browser.

本文标签: powerpointCreating OpenXML documents using JavaScriptStack Overflow