2012-11-15 55 views
5

我處於一種需要以編程方式構建PowerPoint演示文稿並通過Web應用程序提供所產生的ppt文件的情況,最好使用Rails,JavaScript或Ruby。這可能嗎?如果是這樣,如何以及使用哪些工具?使用Rails創建幻燈片演示文稿

我願意接受任何和所有關於如何最好地解決這個問題的建議。謝謝!

+1

是否需要一個PowerPoint文件或將創建在全屏瀏覽器中運行的HTML呈現夠嗎? – Bergi

+0

它需要是一個powerpoint文件。 – MalSu

+0

好的;所以你在談論服務器端JavaScript? – Bergi

回答

4

http://tomasvarsavsky.com/2009/04/04/simple-word-document-templating-using-ruby-and-xml/

如果你可以創建模板和填充值,可以考慮這種方式。

的Office Open XML文件格式

新的Office文件格式(.DOCX,.XLSX,.pptx格式)基本的XML文件的壓縮集合。我們專注於Word文件 (.docx),但此方法也適用於其他任何類型的 文件。格式規格的權重在幾個 萬頁。從頭開始生成一個沒有目的的文件 處理所有格式錯綜複雜的庫將是一個任務,相當於 。相反,我們在Word中起草了模板,並將標記 告訴我們的模板引擎在哪裏插入值。我們創建了 文檔屬性,它引用數據值並將它們作爲 字段添加到插入值爲 的位置的文檔中。例如,我們可以像字段:

label_tag #{data[:user].name} 
label_tag #{data[:user].address} 
label_tag #{data[:booking].number} 
label_tag #{data[:booking].items.collect{|i| i.name}.join(‘,’)} 

否則,有一個嘗試(WIP上傳三年前,我不希望它被完成,而應該在創造一種方法來創建是benfecial幻燈片)創建PowerPoint幻燈片。下面是代碼

https://github.com/jpoz/rubypoint/blob/master/lib/rubypoint/presentation.rb

def new_slide 
    RubyPoint::Slide.new(self) 
end 
+0

謝謝!今晚我會看看這個! – MalSu

+0

這是完美的指導,我接受它作爲答案,謝謝! – MalSu

+0

您是否找到使用此解決方案的解決方案?我有類似的問題 – Joelio

4

這紅寶石寶石的樣本似乎比當前接受的答案中提到的一個更加成熟。

https://github.com/pythonicrubyist/powerpoint http://rubygems.org/gems/powerpoint

require 'powerpoint' 

@deck = Powerpoint::Presentation.new 

# Creating an introduction slide: 
title = 'Bicycle Of the Mind' 
subtitle = 'created by Steve Jobs' 
@deck.add_intro title, subtitle 

# Creating a text-only slide: 
# Title must be a string. 
# Content must be an array of strings that will be displayed as bullet items. 
title = 'Why Mac?' 
content = ['Its cool!', 'Its light.'] 
@deck.add_textual_slide title, content 

# Creating an image Slide: 
# It will contain a title as string. 
# and an embeded image 
title = 'Everyone loves Macs:' 
image_path = 'samples/images/sample_gif.gif' 
@deck.add_pictorial_slide title, image_path 

# Specifying coordinates and image size for an embeded image. 
# x and y values define the position of the image on the slide. 
# cx and cy define the width and height of the image. 
# x, y, cx, cy are in points. Each pixel is 12700 points. 
# coordinates parameter is optional. 
coords = {x: 124200, y: 3356451, cx: 2895600, cy: 1013460} 
@deck.add_pictorial_slide title, image_path, coords 

# Saving the pptx file to the current directory. 
@deck.save('test.pptx') 
相關問題