View | Details | Raw Unified | Return to bug 15324
Collapse All | Expand All

(-)src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java (+56 lines)
Lines 63-68 Link Here
63
import org.apache.poi.hssf.record.BOFRecord;
63
import org.apache.poi.hssf.record.BOFRecord;
64
import org.apache.poi.hssf.record.EOFRecord;
64
import org.apache.poi.hssf.record.EOFRecord;
65
import org.apache.poi.hssf.util.CellReference;
65
import org.apache.poi.hssf.util.CellReference;
66
import org.apache.poi.hssf.util.HSSFColor;
66
67
67
import java.io.File;
68
import java.io.File;
68
import java.io.FileInputStream;
69
import java.io.FileInputStream;
Lines 139-144 Link Here
139
            in.close();
140
            in.close();
140
    }
141
    }
141
142
143
    /**
144
     * test that Cell Styles being applied to formulas remain intact
145
     */
146
    public void testFormulaStyle()
147
            throws java.io.IOException {
148
        String readFilename = System.getProperty("HSSF.testdata.path");
149
150
            File file = File.createTempFile("testBoolErr",".xls");
151
            FileOutputStream out    = new FileOutputStream(file);
152
            HSSFWorkbook     wb     = new HSSFWorkbook();
153
            HSSFSheet        s      = wb.createSheet("Sheet1");
154
            HSSFRow          r      = null;
155
            HSSFCell         c      = null;
156
            HSSFCellStyle cs = wb.createCellStyle();
157
            HSSFFont f = wb.createFont();
158
            f.setFontHeightInPoints((short) 20);
159
            f.setColor((short) HSSFColor.RED.index);
160
            f.setBoldweight(f.BOLDWEIGHT_BOLD);
161
            f.setFontName("Arial Unicode MS");
162
            cs.setFillBackgroundColor((short)3);
163
            cs.setFont(f);
164
            cs.setBorderTop((short)1);
165
            cs.setBorderRight((short)1);
166
            cs.setBorderLeft((short)1);
167
            cs.setBorderBottom((short)1);
168
            
169
            r = s.createRow((short)0);
170
            c=r.createCell((short)0);
171
            c.setCellStyle(cs);
172
            c.setCellFormula("2*3");
173
            
174
            wb.write(out);
175
            out.close();
176
177
            assertTrue("file exists",file.exists());
178
179
            FileInputStream in = new FileInputStream(file);
180
            wb = new HSSFWorkbook(in);
181
            s = wb.getSheetAt(0);
182
            r = s.getRow(0);
183
            c = r.getCell((short)0);
184
            
185
            assertTrue("Formula Cell at 0,0", (c.getCellType()==c.CELL_TYPE_FORMULA));
186
            cs = c.getCellStyle();
187
            
188
            assertNotNull("Formula Cell Style", cs);
189
            assertTrue("Font Index Matches", (cs.getFontIndex() == f.getIndex()));
190
            assertTrue("Top Border", (cs.getBorderTop() == (short)1));
191
            assertTrue("Left Border", (cs.getBorderLeft() == (short)1));
192
            assertTrue("Right Border", (cs.getBorderRight() == (short)1));
193
            assertTrue("Bottom Border", (cs.getBorderBottom() == (short)1));
194
            
195
            in.close();
196
    }    
197
    
142
    public static void main(String [] args) {
198
    public static void main(String [] args) {
143
        System.out
199
        System.out
144
        .println("Testing org.apache.poi.hssf.usermodel.TestHSSFCell");
200
        .println("Testing org.apache.poi.hssf.usermodel.TestHSSFCell");

Return to bug 15324