SeamFramework.orgCommunity Documentation

第19章 Microsoft® Excel® スプレッドアプリケーション

19.1. Microsoft® Excel® スプレッドアプリケーションを利用する
19.2. 簡単なブックを作成する
19.3. workbook要素
19.4. worksheet要素
19.5. column要素
19.6. cell要素
19.6.1. validation要素
19.6.2. 書式マスク
19.7. formula要素
19.8. image要素
19.9. hyperlink要素
19.10. header要素とfooter要素
19.11. printArea要素とprintTitle要素
19.12. ワークシートコマンド要素
19.12.1. グルーピング
19.12.2. 改ページ要素
19.12.3. 結合要素
19.13. データテーブルへの出力
19.14. フォントとレイアウト
19.14.1. スタイルシートへのリンク
19.14.2. フォント
19.14.3. ボーダー
19.14.4. 背景
19.14.5. 列の設定
19.14.6. セルの設定
19.14.7. データテーブル出力
19.14.8. レイアウト例
19.14.9. 制限
19.15. Internationalization
19.16. 関連リンクと詳細なドキュメント

Seamでは素晴らしいJExcelAPI ライブラリを通じて、Microsoft® Excel® スプレッドアプリケーションのスプレッドシートを作成することもできます。作成されたドキュメントはthe Microsoft® Excel® spreadsheet applicationの95、97、2000、XP、2003の各バージョンと互換性があります。現在のところは、ライブラリの機能の内、限定的にいくつかの機能が使えるのみですが、ライブラリで可能なすべてのことをSeamでも可能にすることが最終的な目標です。Seamで可能な操作、今のところ不可能な操作について詳しく知りたい場合は、JExcelAPIのドキュメントを参照して下さい。

The Microsoft® Excel® spreadsheet application jboss-seam-excel.jar. This JAR contains the the Microsoft® Excel® spreadsheet application JSF controls, which are used to construct views that can render the document, and the DocumentStore component, which serves the rendered document to the user. To include the Microsoft® Excel® spreadsheet application support in your application, include jboss-seam-excel.jar in your WEB-INF/lib directory along with the jxl.jar JAR file. Furthermore, you need to configure the DocumentStore servlet in your web.xml

Microsoft® Excel® スプレッドアプリケーションのためのSeamモジュールではビューテクノロジーとして Facelets を使用する必要があります。また、 seam-ui パッケージの使用も必要となります。

examples/excel プロジェクトには実行可能なMicrosoft® Excel® スプレッドアプリケーションのサンプルが含まれています。 サンプルを用いて、適切なデプロイメントや主要な機能を体験することができます。

Microsoft® Excel® スプレッドアプリケーションのスプレッドシートAPIのさまざまな機能を使用するためにモジュールをカスタマイズすることが簡単にできます。ExcelWorkbookインタフェースを実装し、それをcomponents.xmlに登録して下さい。


<excel:excelFactory>
   <property name="implementations">
      <key
>myExcelExporter</key>
      <value
>my.excel.exporter.ExcelExport</value>
   </property>
</excel:excelFactory
>
      

そして、excel名前空間をcomponentsタグに登録して下さい。


xmlns:excel="http://jboss.com/products/seam/excel"

あとは、myExcelExporterオブジェクトにUIWorkbook型を設定すると、作成した出力モジュールが使用されます。デフォルトは"jxl"ですが、"csv"を指定することによって、CSV出力を使用することもできます。

ドキュメントを.xls拡張子とともに出力するためのサーブレットの設定の仕方については項18.6. 「iText を設定する」を参照して下さい。

もし、IEで(特にhttpsで)、作成されたファイルを開いた際に問題が発生した場合は、ブラウザの制限が厳しすぎないか(http://www.nwnetworks.com/iezones.htm/を参照)、web.xmlでのセキュリティ制約が厳しすぎないか、またはその両方を確認して下さい。

シートを利用するための基本は簡単です。それは、使いなれた<h:dataTable>に似ており、ListSetMapArrayDataModelに結びつけることができます。



            <e:workbook xmlns:e="http://jboss.com/products/seam/excel">
               <e:worksheet>
                  <e:cell column="0" row="0" value="Hello world!"/>
               </e:worksheet>
            </e:workbook>
        
      

これはあまり使える例ではありません。もう少し一般的な例を見てみましょう。



            <e:workbook xmlns:e="http://jboss.com/products/seam/excel">
               <e:worksheet value="#{data}" var="item">
                  <e:column>
                     <e:cell value="#{item.value}"/>
                  </e:column>
               </e:worksheet>
            </e:workbook>
         
      

はじめに、一番外側にはworkbook要素を置きます。これは、箱の役割を果たし、なんの属性も持ちません。その子要素として、worksheet要素を置きます。worksheet要素は二つの属性を持ちます。value="#{data}"はデータを結びつけるためのEL式であり、var="item"は現在のアイテムの名前です。worksheet要素の中には、一つだけcolumn要素があり、その中にはcell要素があります。cell要素はデータの中の列挙されたアイテムの内、現在のアイテムを、最終的に結び付けます。

データをシートに出力するための手始めはこれですべてです。

workbook要素は、一番外側の要素であり、worksheet要素やスタイルシートのためのlink要素の親となります。

<e:workbook>

属性

  • type — Defines which export module to be used. The value is a string and can be either "jxl" or "csv". The default is "jxl".

  • templateURI — A template that should be used as a basis for the workbook. The value is a string (URI).

  • arrayGrowSize — The amount of memory by which to increase the amount of memory allocated to storing the workbook data. For processes reading many small workbooks inside a WAS it might be necessary to reduce the default size. Default value is 1 megabyte. The value is a number (bytes).

  • autoFilterDisabled — Should autofiltering be disabled?. The value is a boolean.

  • cellValidationDisabled — Should cell validation be ignored? The value is a boolean.

  • characterSet — The character set. This is only used when the spreadsheet is read, and has no effect when the spreadsheet is written. The value is a string (character set encoding).

  • drawingsDisabled — Should drawings be disabled? The value is a boolean.

  • excelDisplayLanguage — The language in which the generated file will display. The value is a string (two character ISO 3166 country code).

  • excelRegionalSettings — The regional settings for the generated excel file. The value is a string (two character ISO 3166 country code).

  • formulaAdjust — Should formulas be adjusted? The value is a boolean.

  • gcDisabled — Should garbage collection be disabled? The value is a boolean.

  • ignoreBlanks — Should blanks be ignored? The value is a boolean.

  • initialFileSize — The initial amount of memory allocated to store the workbook data when reading a worksheet. For processes reading many small workbooks inside a WAS it might be necessary to reduce the default size. Default value is 5 megabytes. The value is a number (bytes).

  • locale — The locale used by JExcelApi to generate the spreadsheet. Setting this value has no effect on the language or region of the generated excel file. The value is a string.

  • mergedCellCheckingDisabled — Should merged cell checking be disabled? The value is a boolean.

  • namesDisabled — Should handling of names be disabled? The value is a boolean.

  • propertySets — Should any property sets be enabled (such as macros) to be copied along with the workbook? Leaving this feature enabled will result in the JXL process using more memory. The value is a boolean.

  • rationalization — Should the cell formats be rationalized before writing out the sheet? The value is a boolean. Default is true.

  • supressWarnings — Should warnings be suppressed?. Due to the change in logging in version 2.4, this will now set the warning behaviour across the JVM (depending on the type of logger used). The value is a boolean.

  • temporaryFileDuringWriteDirectory — Used in conjunction with the useTemporaryFileDuringWrite setting to set the target directory for the temporary files. This value can be NULL, in which case the normal system default temporary directory is used instead. The value is a string (the directory to which temporary files should be written).

  • useTemporaryFileDuringWrite — Should a temporary file is used during the generation of the workbook. If not set, the workbook will take place entirely in memory. Setting this flag involves an assessment of the trade-offs between memory usage and performance. The value is a boolean.

  • workbookProtected — Should the workbook be protected? The value is a boolean.

  • filename — The filename to use for the download. The value is a string. Please note that if you map the DocumentServlet to some pattern, this file extension must also match.

  • exportKey — A key under which to store the resulting data in a DocumentData object under the event scope. If used, there is no redirection.

子要素

ファセット

  • なし



            <e:workbook>
               <e:worksheet>
                  <e:cell value="Hello World" row="0" column="0"/>
               </e:worksheet>
            <e:workbook>
         
      

これは、一つシートを持ち、そのA1セルに挨拶が書かれたブックを定義します。

Worksheets are the children of workbooks and the parent of columns and worksheet commands. They can also contain explicitly placed cells, formulas, images and hyperlinks. They are the pages that make up the workbook.

<e:worksheet>

  • value — An EL-expression to the backing data. The value is a string. The target of this expression is examined for an Iterable. Note that if the target is a Map, the iteration is done over the Map.Entry entrySet(), so you should use a .key or .value to target in your references.

  • var — The current row iterator variable name that can later be referenced in cell value attributes. The value is a string.

  • name — The name of the worksheet. The value is a string. Defaults to Sheet# where # is the worksheet index. If the given worksheet name exists, that sheet is selected. This can be used for merging several data sets into a single worksheet, just define the same name for them (using startRow and startCol to make sure that they don't occupy the same space).

  • startRow — Defines the starting row for the data. The value is a number. Used for placing the data in other places than the upper-left corner (especially useful if having multiple data sets for a single worksheet). The defaults is 0.

  • startColumn — Defines the starting column for the data. The value is a number. Used for placing the data in other places than the upper-left corner (especially useful if having multiple data sets for a single worksheet). The default is 0.

  • automaticFormulaCalculation — Should formulas be automatically calculated? The value is a boolean.

  • bottomMargin — The bottom margin. The value is a number (inches).

  • copies — The number of copies. The value is a number.

  • defaultColumnWidth — The default column width. The value is a number (characters * 256).

  • defaultRowHeight — The default row height. The value is a number (1/20ths of a point).

  • displayZeroValues — Should zero-values be displayed? The value is a boolean.

  • fitHeight — The number of pages vertically that this sheet will be printed into. The value is a number.

  • fitToPages — Should printing be fit to pages? The value is a boolean.

  • fitWidth — The number of pages widthwise which this sheet should be printed into. The value is a number.

  • footerMargin — The margin for any page footer. The value is a number (inches).

  • headerMargin — The margin for any page headers. The value is a number (inches).

  • hidden — Should the worksheet be hidden? The value is a boolean.

  • horizontalCentre — Should the worksheet be centered horizontally? The value is a boolean.

  • horizontalFreeze — The row at which the pane is frozen vertically. The value is a number.

  • horizontalPrintResolution — The horizontal print resolution. The value is a number.

  • leftMargin — The left margin. The value is a number (inches).

  • normalMagnification — The normal magnification factor (not zoom or scale factor). The value is a number (percentage).

  • orientation — The paper orientation for printing this sheet. The value is a string that can be either "landscape" or "portrait".

  • pageBreakPreviewMagnification — The page break preview magnification factor (not zoom or scale factors). The value is a number (percentage).

  • pageBreakPreviewMode — Show page in preview mode? The value is a boolean.

  • pageStart — The page number at which to commence printing. The value is a number.

  • paperSize — The paper size to be used when printing this sheet. The value is a string that can be one of "a4", "a3", "letter", "legal" etc (see jxl.format.PaperSize ).

  • password — The password for this sheet. The value is a string.

  • passwordHash — The password hash - used only when copying sheets. The value is a string.

  • printGridLines — Should grid lines be printed? The value is a boolean.

  • printHeaders — Should headers be printed? The value is a boolean.

  • sheetProtected — Should the sheet be protected (read-only)? The value is a boolean.

  • recalculateFormulasBeforeSave — Should the formulas be re-calculated when the sheet is saved? The value is a boolean. Default value is false.

  • rightMargin — The right margin. The value is a number (inches).

  • scaleFactor — The scale factor for this sheet to be used when printing. The value is a number (percent).

  • selected — Should the sheet be selected when the workbook opens? The value is a boolean.

  • showGridLines — Should gridlines be shown? The value is a boolean.

  • topMargin — The top margin. The value is a number (inches).

  • verticalCentre — Center verically? The value is a boolean.

  • verticalFreeze — The row at which the pane is frozen vertically. The value is a number.

  • verticalPrintResolution — The vertical print resolution. The value is a number.

  • zoomFactor — The zoom factor. Do not confuse zoom factor (which relates to the on screen view) with scale factor (which refers to the scale factor when printing). The value is a number (percentage).

子要素

ファセット

  • header— Contents that will be placed at the top of the data block, above the column headers (if any).

  • footer— Contents that will be placed at the bottom of the data block, below the column footers (if any).



            <e:workbook>
               <e:worksheet name="foo" startColumn="1" startRow="1">
                      <e:column value="#{personList}" var="person">
                         <f:facet name="header">
                            <e:cell value="Last name"/>
                         </f:facet>
                     <e:cell value="#{person.lastName}"/>
                  </e:column>
               </e:worksheet>
            <e:workbook>
         
      

これはB2セルから表示が開始される、"foo"という名前のワークシートを定義します。

column要素は、worksheet要素の子要素で、cell要素、image要素、formula要素、hyperlink要素の親要素です。これらはワークシートのデータ列挙を制御するためのタグになります。書式の制御については項19.14.5. 「列の設定」を参照して下さい。

<e:column>

属性

  • なし

子要素

ファセット

  • header — This facet can/will contain one <e:cell> , <e:formula> , <e:image> or <e:hyperLink> that will be used as header for the column.

  • footer — This facet can/will contain one <e:cell> , <e:formula> , <e:image> or <e:hyperLink> that will be used as footer for the column.



            <e:workbook>
                   <e:worksheet>
                      <e:column value="#{personList}" var="person">
                         <f:facet name="header">
                            <e:cell value="Last name"/>
                         </f:facet>
                         <e:cell value="#{person.lastName}"/>
                      </e:column>
                   </e:worksheet>
            <e:workbook>
         
      

これは、ヘッダーと値の列挙からなる列を定義します。

Cells are nested within columns (for iteration) or inside worksheets (for direct placement using the column and row attributes) and are responsible for outputting the value (usually through an EL-expression involving the var-attribute of the datatable. See ???

<e:cell>

属性

  • column — The column where to place the cell. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • row — The row where to place the cell. The default is the internal counter. The value is number. Note that the value is 0-based.

  • value — The value to display. Usually an EL-expression referencing the var-attribute of the containing datatable. The value is a string.

  • comment — A comment to add to the cell. The value is a string.

  • commentHeight — The height of the comment. The value is a number (in pixels).

  • commentWidth — A width of the comment. The value is a number (in pixels).

子要素

ファセット

  • なし



            <e:workbook>
               <e:worksheet
>         
                  <e:column value="#{personList}" var="person">
                     <f:facet name="header">
                            <e:cell value="Last name"/>
                         </f:facet>
                         <e:cell value="#{person.lastName}"/>
                      </e:column>
               </e:worksheet>
            </e:workbook
>     
         
      

これは、ヘッダーと値の列挙からなる列を定義します。

Validations are nested inside cells or formulas. They add constrains for the cell data.

<e:numericValidation>

属性

  • value — The limit (or lower limit where applicable) of the validation. The value is a number.

  • value2 — The upper limit (where applicable) of the validation. The value is a number.

  • condition — The validation condition. The value is a string.

    • "equal" - セルの値はvalue属性で指定された値と等しい必要があります。

    • "greater_equal" - セルの値はvalue属性で指定された値より大きい、もしくは等しい必要があります。

    • "less_equal" - セルの値はvalue属性で指定された値より小さい、もしくは等しい必要があります。

    • "less_than" - セルの値はvalue属性で指定された値より小さい必要があります。

    • "not_equal" - セルの値はvalue属性で指定された値とひとしくない必要があります。

    • "between" - セルの値はvalue属性で指定された値とvalue2で指定された値の間の値である必要があります。

    • "not_between" - セルの値はvalue属性で指定された値とvalue2で指定された値の間の値でない必要があります。

子要素

  • なし

ファセット

  • なし



               <e:workbook>
                  <e:worksheet>
                     <e:column value="#{personList}" var="person"
>                   
                        <e:cell value="#{person.age">
                           <e:numericValidation condition="between" value="4" 
                              value2="18"/>
                        </e:cell>
                     </e:column>
                  </e:worksheet>
               </e:workbook
>            
            
         

これは、値が4と18の間の値でなければならないというバリデーション条件をセルに付加します。

<e:rangeValidation>

属性

  • startColumn — The starting column of the range of values to validate against. The value is a number.

  • startRow — The starting row of the range of values to validate against. The value is a number.

  • endColumn — The ending column of the range of values to validate against. The value is a number.

  • endRow — The ending row of the range of values to validate against. The value is a number.

子要素

  • なし

ファセット

  • なし



               <e:workbook>
                  <e:worksheet>
                     <e:column value="#{personList}" var="person"
>                   
                            <e:cell value="#{person.position">
                           <e:rangeValidation startColumn="0" startRow="0" 
                              endColumn="0" endRow="10"/>
                        </e:cell>
                     </e:column>
                  </e:worksheet>
               </e:workbook
>            
            
         

これは、値がA1:A10の範囲にある値のどれかでなければならないというバリデーション条件をセルに付加します。

<e:listValidation>

属性

  • なし

子要素

  • 0個以上のlistValidationItem要素

ファセット

  • なし

e:listValidation要素は、複数のe:listValidationItem要素を保持するための、ただの入れ物です。

<e:listValidationItem>

属性

  • value — A values to validate against.

子要素

  • なし

ファセット

  • なし



               <e:workbook>
                  <e:worksheet>
                     <e:column value="#{personList}" var="person"
>            
                        <e:cell value="#{person.position">
                           <e:listValidation>
                              <e:listValidationItem value="manager"/>
                              <e:listValidationItem value="employee"/>
                           </e:listValidation>
                        </e:cell>
                     </e:column>
                  </e:worksheet>
               </e:workbook
>              
            
         

これは、セルの値が"manager"もしくは"employee"でなければならないというバリデーション条件をセルに付加します。

Format masks are defined in the mask attribute in cells or formulas. There are two types of format masks, one for numbers and one for dates

書式マスクがあった場合、まずそれが組み込みの形式であるかどうかがチェックされます。組み込みの形式は例えば、"format1"や"accounting_float"のようなものです( jxl.write.NumberFormats を参照して下さい。)

マスクがリストになかった場合は、カスタムマスクとして扱われます( java.text.DecimalFormat を参照下さい)。例えば"0.00"であったり、自動的に一番近いものに変換された書式が採用されます。

書式マスクがあった場合、まずそれが組み込みの形式であるかどうかがチェックされます。組み込みの形式は例えば、"format1"や"format2"のようなものです( jxl.write.DecimalFormats を参照して下さい)。

マスクがリストになかった場合は、カスタムマスクとして扱われます( java.text.DateFormat を参照して下さい)。例えば"dd.MM.yyyy"であったり、自動的に一番近いものに変換された書式が採用されます。

formula要素は、column要素の中(値の列挙のため)、あるいはworksheet要素の中(column属性とrow属性を用いた直接的な配置のため)に置かれ、ある範囲のセル値の計算や関数の適用を行います。formula要素は本質的にセルなので、利用可能な属性を見るためには項19.6. 「cell要素」を参照して下さい。formula要素は、テンプレートにも適用することができ、通常のセルと同様、独自のフォントなどの定義を持つこともできることに注意して下さい。

The formula of the cell is placed in the value -attribute as a normal the Microsoft® Excel® spreadsheet application notation. Note that when doing cross-sheet formulas, the worksheets must exist before referencing a formula against them. The value is a string.



            <e:workbook>
               <e:worksheet name="fooSheet">
                  <e:cell column="0" row="0" value="1"/>
               </e:worksheet>
               <e:worksheet name="barSheet">
                  <e:cell column="0" row="0" value="2"/>
                  <e:formula column="0" row="1" 
                     value="fooSheet!A1+barSheet1!A1">
                     <e:font fontSize="12"/>
                  </e:formula>
               </e:worksheet>
            </e:workbook>         
         
      

これは、BarSheetのB1セルに、FooSheetとBarSheetのA1セル同士を加算する式を定義します。

image要素は、column要素の中(値の列挙のため)、あるいはworksheet要素の中(startColumn/startRow属性とrowSpan/columnSpan属性を用いた直接的な配置のため)に置かれます。spanはオプションであり、省略された場合は、画像はリサイズされずに挿入されます。

<e:image>

属性

  • startColumn — The starting column of the image. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • startRow — The starting row of the image. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • columnSpan — The column span of the image. The default is one resulting in the default width of the image. The value is a float.

  • rowSpan — The row span of the image. The default is the one resulting in the default height of the image. The value is a float.

  • URI — The URI to the image. The value is a string.

子要素

  • なし

ファセット

  • なし



            <e:workbook>
               <e:worksheet>
                  <e:image startRow="0" startColumn="0" rowSpan="4" 
                     columnSpan="4" URI="http://foo.org/logo.jpg"/>
               </e:worksheet>
            </e:workbook
>           
         
      

これは、与えられたURIの画像をA1:E5の領域に表示します。

hyperlink要素は、column要素の中(値の列挙のため)、あるいはworksheet要素の中(startColumn/startRow属性とendColumn/endRow属性を用いた直接的な配置のため)に置かれます。これらは、URIに対するリンクを追加します。

<e:hyperlink>

属性

  • startColumn — The starting column of the hyperlink. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • startRow — The starting row of the hyperlink. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • endColumn — The ending column of the hyperlink. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • endRow — The ending row of the hyperlink. The default is the internal counter. The value is a number. Note that the value is 0-based.

  • URL — The URL to link. The value is a string.

  • description — The description of the link. The value is a string.

子要素

  • なし

ファセット

  • なし



            <e:workbook>
               <e:worksheet>
                  <e:hyperLink startRow="0" startColumn="0" endRow="4" 
                     endColumn="4" URL="http://seamframework.org" 
                     description="The Seam Framework"/>
               </e:worksheet>
            </e:workbook
>          
         
      

これは、seamframework.orgのページを指すメッセージ付きリンクを、A1:E5の領域に表示します。

header要素とfooter要素はworksheet要素の子要素であり、facet要素を含み、facet要素は、コマンドの埋め込まれた文字列を含みます。文字列は構文解析され、コマンドの結果を含んだ文字列として表示されます。

<e:header>

属性

  • なし

子要素

  • なし

ファセット

  • left — The contents of the left header/footer part.

  • center — The contents of the center header/footer part.

  • right — The contents of the right header/footer part.

<e:footer>

属性

  • なし

子要素

  • なし

ファセット

  • left — The contents of the left header/footer part.

  • center — The contents of the center header/footer part.

  • right — The contents of the right header/footer part.

facet要素の内容には、以下のように#で区切られたさまざまなコマンドを含めることができます。

#date#

現在の日付を挿入します。

#page_number#

現在のページを挿入します。

#time#

現在の時刻を挿入します。

#total_pages#

総ページ数を挿入します。

#worksheet_name#

シート名を挿入します。

#workbook_name#

ブック名を挿入します。

#bold#

強調文字に切り替えます。次の#bold#まで有効となります。

#italics#

斜体文字に切り替えます。次の#italic#まで有効となります。

#underline#

下線を引きます。次の#underline#まで有効となります。

#double_underline#

二重下線を引きます。次の#double_underline#まで有効となります。

#outline#

アウトラインフォントに切り替えます。次の#outline#まで有効となります。

#shadow#

影付き文字に切り替えます。次の#shadow#まで有効となります。

#strikethrough#

取り消し線を引きます。次の#strikethrough#まで有効となります。

#subscript#

下付き文字に切り替えます。次の#subscript#まで有効となります。

#superscript#

上付き文字に切り替えます。次の#superscript#まで有効となります。

#superscript#

フォント名を設定します。#font_name=Verdana#のように設定します。

#font_size#

フォントサイズを設定します。#font_size=12#のように設定します。



            <e:workbook>
               <e:worksheet
>         
                  <e:header>
                     <f:facet name="left">
                        This document was made on #date# and has #total_pages# pages
                     </f:facet>
                     <f:facet name="right">
                        #time#
                     </f:facet>
                  </e:header>
               <e:worksheet>
            </e:workbook>
         
      

printArea要素とprintTitle要素はワークシートやワークシートテンプレートの子要素であり、印刷範囲や印刷タイトルを設定します。

<e:printArea>

属性

  • firstColumn — The column of the top-left corner of the area. The parameter is a number. Note that the value is 0-based.

  • firstRow — The row of the top-left corner of the area. The parameter is a number. Note that the value is 0-based.

  • lastColumn — The column of the bottom-right corner of the area. The parameter is a number. Note that the value is 0-based.

  • lastRow — The row of the bottom-right corner of the area. The parameter is a number. Note that the value is 0-based.

子要素

  • なし

ファセット

  • なし



            <e:workbook>
               <e:worksheet
>            
                  <e:printTitles firstRow="0" firstColumn="0" 
                     lastRow="0" lastColumn="9"/>
                  <e:printArea firstRow="1" firstColumn="0" 
                     lastRow="9" lastColumn="9"/>
               </e:worksheet>
            </e:workbook>
         
      

これは、A1:A10の領域を印刷タイトルとし、B2:J10の領域を印刷範囲とします。

ワークシートコマンド要素はworkbook要素の子要素であり、通常一回だけ実行されます。

行や列のグルーピングを行います。

<e:groupRows>

属性

  • startRow — The row to start the grouping at. The value is a number. Note that the value is 0-based.

  • endRow — The row to end the grouping at. The value is a number. Note that the value is 0-based.

  • collapse — Should the grouping be collapsed initially? The value is a boolean.

子要素

  • なし

ファセット

  • なし

<e:groupColumns>

属性

  • startColumn — The column to start the grouping at. The value is a number. Note that the value is 0-based.

  • endColumn — The column to end the grouping at. The value is a number. Note that the value is 0-based.

  • collapse — Should the grouping be collapsed initially? The value is a boolean.

子要素

  • なし

ファセット

  • なし



               <e:workbook>
                  <e:worksheet
>            
                     <e:groupRows startRow="4" endRow="9" collapse="true"/>
                     <e:groupColumns startColumn="0" endColumn="9" collapse="false"/>
                  </e:worksheet>
               </e:workbook>
            
         

groups rows 5 through 10 and columns 5 through 10 so that the rows are initially collapsed (but not the columns).

セルを結合します。

<e:mergeCells>

属性

  • startRow — The row to start the merging from. The value is a number. Note that the value is 0-based.

  • startColumn — The column to start the merging from. The value is a number. Note that the value is 0-based.

  • endRow — The row to end the merging at. The value is a number. Note that the value is 0-based.

  • endColumn — The column to end the merging at. The value is a number. Note that the value is 0-based.

子要素

  • なし

ファセット

  • なし



               <e:workbook>
                  <e:worksheet>
                     <e:mergeCells startRow="0" startColumn="0" endRow="9" endColumn="9"/>
                  </e:worksheet>
               </e:workbook
>            
            
         

これは、A1:J10の範囲のセルを結合します。

もし、専用のXHMLドキュメントを作成する代わりに、既存のJSFデータテーブルを出力したい場合は、org.jboss.seam.excel.excelExporter.exportコンポーネントを使い、データテーブルのIDをSeamのEL式として渡すことで、簡単に実現することができます。このようなテーブルがあり、



            <h:form id="theForm">
               <h:dataTable id="theDataTable" value="#{personList.personList}" 
                  var="person">
                  ...
               </h:dataTable>
            </h:form>
            
      

これをMicrosoft® Excel®のスプレッドシートとして表示させたい場合は、



            <h:commandLink 
               value="Export" 
               action="#{excelExporter.export('theForm:theDataTable')}"
            />
         
      

のように、フォームの中に記述します。もちろん、ボタンや、s:linkやその他の手段によって、出力を実行することもできます。データテーブルの中に専用の出力用のタグを記述できるようにする計画もあり、そうするとデータテーブルのIDを渡さなくても済むようになります。

フォーマット処理については項19.14. 「フォントとレイアウト」を参照して下さい。

CSS風のスタイル属性とタグ属性を組み合わせて、出力の見た目を制御することができます。最も汎用的なもの(font、border、backgroundなど)はCSSで記述でき、そうでないものはタグ属性で記述できます。

The CSS attributes cascade down from parent to children and within one tag cascades over the CSS classes referenced in the styleClass attributes and finally over the CSS attributes defined in the style attribute. You can place them pretty much anywhere but e.g. placing a column width setting in a cell nested within that column makes little sense.

以下のXLS-CSS属性のグループは、フォントとその属性を定義します。

xls-font-family

フォント名です。フォントがOSによってサポートされていることを確認して下さい。

xls-font-size

フォントサイズです。値は数値です。

xls-font-color

フォントの色です( jxl.format.Colour を参照して下さい)。

xls-font-bold

フォントを強調文字にするかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-font-italic

フォントを斜体文字にするかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-font-script-style

フォントの上付きや下付きを設定します( jxl.format.ScriptStyle を参照して下さい。)

xls-font-underline-style

フォントの下線を設定します( jxl.format.UnderlineStyle を参照して下さい)。

xls-font-struck-out

フォントに取り消し線をつけるかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-font

すべてのフォント設定を略記で行います。フォント名は'Times New Roman'のようにスペース区切りにして、記述の一番最後に置きます。"italic"や"bold"や"struckout"などを使用することができます。

Example style="xls-font: red bold italic 22 Verdana"

This group of XLS-CSS attributes defines the borders of the cell

xls-border-left-color

セルの左ボーダーの色です( jxl.format.Colour を参照して下さい)。

xls-border-left-line-style

セルの左ボーダーのスタイルです( jxl.format.LineStyle を参照して下さい)。

xls-border-left

セルの左ボーダーの色とスタイルの設定を略記で行います。例えばstyle="xls-border-left: thick red"のようになります。

xls-border-top-color

セルの上ボーダーの色です( jxl.format.Colour を参照して下さい)。

xls-border-top-line-style

セルの上ボーダーのスタイルです( jxl.format.LineStyle を参照して下さい)。

xls-border-top

A shorthand for setting line style and color of the top edge of the cell, e.g style="xls-border-top: red thick"

xls-border-right-color

セルの右ボーダーの色です( jxl.format.Colour を参照して下さい)。

xls-border-right-line-style

セルの右ボーダーのスタイルです( jxl.format.LineStyle を参照して下さい)。

xls-border-right

セルの右ボーダーの色とスタイルの設定を略記で行います。例えばstyle="xls-border-right: thick red"のようになります。

xls-border-bottom-color

セルの下ボーダーの色です( jxl.format.Colour を参照して下さい)。

xls-border-bottom-line-style

セルの下ボーダーのスタイルです( jxl.format.LineStyle を参照して下さい)。

xls-border-bottom

セルの下ボーダーの色とスタイルの設定を略記で行います。例えばstyle="xls-border-bottom: thick red"のようになります。

xls-border

セルの上下左右のボーダーの色とスタイルの設定を略記で行います。例えばstyle="xls-border: thick red"のようになります。

This group of XLS-CSS attributes defines the background of the cell

xls-background-color

背景の色です( jxl.format.LineStyle )を参照して下さい。

xls-background-pattern

背景のパターンです( jxl.format.Pattern を参照して下さい)。

xls-background

背景の色とパターンの設定を略記で行います。記述のルールについては上を参照して下さい。

This group of XLS-CSS attributes defines the column widths etc.

xls-column-width

列幅です。最初は大きめの値(5000まで)を使って下さい。XHTMLモードで使用され、e:columnタグで適用されます。

xls-column-widths

列幅です。最初は大きめの値(5000まで)を使って下さい。データテーブルの出力時に使用され、データテーブルのスタイル属性で適用されます。数値、あるいは、元の設定を有効にするためには"*"を指定して下さい。

Example style="xls-column-widths: 5000, 5000, *, 10000"

xls-column-autosize

列幅の自動調整を行うかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-column-hidden

列を非表示にするかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-column-export

Should the column be shown in export? Valid values are "true" and "false". Default is "true".

This group of XLS-CSS attributes defines the cell properties

xls-alignment

セル値の水平方向の配置を設定します( jxl.format.Alignment を参照して下さい)。

xls-force-type

セルのデータ型を強制します。値は文字列で、"general"、"number"、"text"、"date"、"formula"、"bool"のどれかです。データ型は自動的に検出されるので、この属性を使うことはまれです。

xls-format-mask

セルの書式マスクを設定します。項19.6.2. 「書式マスク」を参照して下さい。 項19.6.2. 「書式マスク」

xls-indentation

セル値のインデントを設定します。値は数値です。

xls-locked

セルをロックするかどうかを設定します。ブックレベルでのロックとともに使用します。"true"もしくは"false"を設定して下さい。

xls-orientation

セル値の方向を設定します( jxl.format.Orientation を参照して下さい)。

xls-vertical-alignment

セル値の垂直方向の配置を設定します( jxl.format.VerticalAlignment を参照して下さい)。

xls-shrink-to-fit

セル値をセルに合わせて縮小するかどうかを設定します。"true"もしくは"false"を設定して下さい。

xls-wrap

セル値を折り返すかどうかを設定します。"true"もしくは"false"を設定して下さい。

There are only two resources bundle keys used, both for invalid data format and both take a parameter (the invalid value)

The core of the the Microsoft® Excel® spreadsheet application functionality is based on the excellent JExcelAPI library which can be found on http://jexcelapi.sourceforge.net/ and most features and possible limitations are inherited from here.

フォーラムやメーリングリストに参加する場合は、そこでの参加者がSeamやライブラリの使い方に関するすべてを知っているわけではないということ、また、そこでのすべての問題はJBoss Seam JIRAの"excel"モジュール以下にもレポート済みであるということを気にとめておいて下さい。