2017-03-03 18 views
0

我想在docx4j/xlsx4j中創建一個簡單的電子表格。它只能包含字符串,不需要公式。該porpuse基本上從一個CSV切換到XLSX 因此,我嘗試在這裏的例子:https://github.com/plutext/docx4j/blob/master/src/samples/xlsx4j/org/xlsx4j/samples/CreateSimpleSpreadsheet.java 不幸的是它不工作。即使在刪除棄用的零件(http://pastebin.com/bUnJWmFD)之後。docx4j/xlsx4j:創建簡單的電子表格

Excel報告不可讀的內容並提出修復建議。之後,我收到錯誤消息:「EntfernteDatensätze:Zellinformationen von /xl/worksheets/sheet1.xml-Part」。它意味着像「刪除的數據集:Cellinformation at /xl/worksheets/sheet1.xml-Part」。

createCell被稱爲行58這個錯誤occures(見Github上,而不是引擎收錄。)或cell.setV被調用的"Hello World"代替"1234"

回答

1

我覺得你在這裏提出2個問題:

  1. 得到的XLSX需要修復:這是由於cell2.setR中的拼寫錯誤,修復爲https://github.com/plutext/docx4j/commit/7d04a65057ad61f5197fb9a98168fc654220f61f
  2. 使用「Hello World」調用setV,您不應該那樣做。每http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/v.html

This element expresses the value contained in a cell. If the cell contains a string, then this value is an index into the shared string table, pointing to the actual string value. Otherwise, the value of the cell is expressed directly in this element. .. For applications not wanting to implement the shared string table, an 'inline string' may be expressed in an <is> element under <c> (instead of a <v> element under <c>),in the same way a string would be expressed in the shared string table.

但我想我們SETV方法可檢測誤用,要麼拋出一個異常,或做其他的事情,而不是一個。

CreateSimpleSpreadsheet示例演示如何設置內聯字符串,因此您只需測試輸入是否爲數字。

+0

感謝您的回覆,您的承諾對我有用! 我希望您知道,我的董事會沒有收到任何激活電子郵件(嘗試了不同的電子郵件地址),網址爲http://www.docx4java.org/forums/。因此,我來​​到這個問題stackoverflow。 – froehli

+1

是的,我們已經升級了服務器,但直到昨天才安裝了sendmail!謝謝。 – JasonPlutext