01: package com.xoetrope.export.xl;
02:
03: import com.xoetrope.export.ArrayArrayBlock;
04: import com.xoetrope.export.Block;
05: import com.xoetrope.export.RowBlock;
06: import com.xoetrope.export.TableBlock;
07: import java.util.ArrayList;
08: import jxl.write.WritableSheet;
09: import net.xoetrope.xui.helper.XTranslator;
10:
11: /**
12: *
13: * <p> Copyright (c) Xoetrope Ltd., 2002-2006, This software is licensed under
14: * the GNU Public License (GPL), please see license.txt for more details</p>
15: * <p>$Revision: 1.5 $</p>
16: */
17: public class XLArrayArrayBlock extends ArrayArrayBlock {
18: protected XLExporter xlExporter;
19: protected WritableSheet sheet;
20: protected XTranslator translator;
21:
22: public XLArrayArrayBlock(XLExporter exporter) {
23: xlExporter = exporter;
24: translator = exporter.getCurrentProject().getTranslator();
25: }
26:
27: public void setWorksheet(WritableSheet worksheet) {
28: sheet = worksheet;
29: }
30:
31: protected String exportModel(ArrayList table, boolean includeHeader) {
32: int startRow = 0;
33: int numRows = table.size();
34:
35: ArrayList row0 = (ArrayList) table.get(0);
36: int numCols = row0.size();
37:
38: TableBlock tableExport = xlExporter.getTableBlock();
39:
40: // TableBlock tableExport = xlExporter.getTableBlock();
41: // if ( includeHeader ) {
42: // RowBlock rowBlock = tableExport.addRow();
43: // for ( int col = 0; col < tableModel.getColumnCount(); col++ ) {
44: // //String value = tableModel.getColumnName( col );
45: // String value = table.getTableHeader().getColumnModel().getColumn( col ).getHeaderValue().toString();
46: // if ( translator != null )
47: // value = translator.translate( value );
48: // String style = getHeaderStyle();
49: // Block cellBlockItem = rowBlock.addCell( value, style, 1, 1 );
50: // }
51: // blocks.add( rowBlock );
52: // }
53:
54: for (int i = startRow; i < numRows; i++) {
55: RowBlock rowBlock = tableExport.addRow();
56: ArrayList row = (ArrayList) table.get(i);
57: for (int j = 0; j < numCols; j++) {
58: String value = (String) row.get(j);
59: if (translator != null)
60: value = translator.translate(value);
61:
62: String style = getHeaderStyle();
63: Block cellBlockItem = rowBlock.addCell(value, style, 1,
64: 1);
65: }
66: blocks.add(rowBlock);
67: }
68:
69: return content.toString();
70: }
71: }
|