}catch(Exception e){System.out.println(e);}
testWrite(tbo, "testFormats_out.xls");
}
void testFormats(String finpath, String sheetname){
WorkBookHandle tbo = new WorkBookHandle(finpath);
int color = 5, patern = 25;
FormatHandle fmt1 = new FormatHandle(tbo);
fmt1.setFont("Arial",Font.PLAIN,10);
fmt1.setForegroundColor(FormatHandle.COLOR_LIGHT_BLUE);
fmt1.setFontColor(FormatHandle.COLOR_YELLOW);
fmt1.setBackgroundPattern(FormatHandle.PATTERN_HOR_STRIPES3);
FormatHandle fmt2 = new FormatHandle(tbo);
try{
sheet = tbo.getWorkSheet(sheetname);
// TEST BORDERS
CellHandle bordercell = sheet.getCell("C3");
int borderfmt = bordercell.getFormatId();
sheet.add("MODDY BORDER", "A10");
bordercell = sheet.getCell("A10");
FormatHandle fmx = new FormatHandle(tbo);
fmx.setBorderLineStyle(3);
fmx.setBorderTopColor(FormatHandle.COLOR_LIGHT_BLUE);
fmx.setBorderBottomColor(FormatHandle.COLOR_GREEN);
fmx.setBorderLeftColor(FormatHandle.COLOR_YELLOW);
fmx.setBorderRightColor(FormatHandle.COLOR_BLACK);
fmx.addCell(sheet.add("Great new cell!!", "A1"));
fmx.setFont("Courier",Font.BOLD,12);
fmx.setForegroundColor(FormatHandle.COLOR_BRIGHT_GREEN);
fmx.setBackgroundColor(FormatHandle.COLOR_BLUE);
fmx.setFontColor(FormatHandle.COLOR_BLUE);
fmx.setBackgroundPattern(FormatHandle.PATTERN_HOR_STRIPES3);
CellHandle cell1 = null;
sheet.setHeaderText("Extentech Inc.");
sheet.setFooterText("Created by ExtenXLS:" + WorkBookHandle.getVersion());
String addr = "";
for(int i = 1;i<50;i++){
addr = "h"+String.valueOf(i);
sheet.add(new Long((long)3324.234 * i), addr);
cell1 = sheet.getCell(addr);
cell1.setFormatHandle(fmx);
addr = "i"+String.valueOf(i);
sheet.add("Hello World " + i, addr);
cell1 = sheet.getCell(addr);
cell1.setFormatHandle(fmt1);
}
color = FormatHandle.COLOR_LIGHT_BLUE;
patern = FormatHandle.PATTERN_LIGHT_DOTS;
cell1 = sheet.getCell("H14");
cell1.setFormatHandle(fmt2);
cell1.setVal(44444);
cell1.setForegroundColor(FormatHandle.COLOR_DARK_RED);
cell1.setBackgroundColor(FormatHandle.COLOR_DARK_YELLOW);
cell1.setBackgroundPattern(patern);
cell1.setFontColor(color);
cell1.setVal(555);
System.out.println("CELL FCOLOR: " + cell1.getForegroundColor());
System.out.println("CELL FCOLOR: " + cell1.getBackgroundColor());
}catch(Exception e){System.out.println(e);}
testWrite(tbo, "testFormats1_out.xls");
// FORMAT ID Sharing
// the fastest, no fuss way to use formats
// on multiple cells
WorkSheetHandle sheet1 = null;
try{
sheet1 = tbo.getWorkSheet("Sheet1");
}catch(Exception e){System.out.println(e);}
sheet1.add("Eurostile Template Cell","A1");
int SHAREDFORMAT = 0;
CellHandle b = null;
CellHandle a= null;
try{
b = sheet1.getCell("A1");
b.setFont("Eurostile",Font.BOLD,14);
// set format options
b.setForegroundColor(30);
b.setBackgroundColor(54);
b.setBackgroundPattern(3);
SHAREDFORMAT = b.getFormatId();
for(int t = 1; t<=10;t++){
sheet1.add(new Float(t*67.5),"E" + t);
a = sheet1.getCell("E" + t);
a.setFormatId(SHAREDFORMAT);
}
a.setFont("Tango",Font.BOLD,26);
a.setFontColor(10);
a.setFormatPattern("[h]:mm:ss");
a.setURL("http://www.extentech.com/");
a.setScript(2);
sheet1.moveCell(a,"A10");
a.getCol().setWidth(8000);
tbo.copyWorkSheet(sheetname, sheetname + " Copy");
}catch(Exception e){System.out.println(e);}
// optimize String table by sharing dupe entries
tbo.setDupeStringMode(WorkBookHandle.SHAREDUPES);
tbo.setStringEncodingMode(WorkBookHandle.STRING_ENCODING_COMPRESSED);
//iterate backgrounds
for(int x = 0;x<32;x++){
sheet1.add("Pattern# " + x, "F"+(x+1));
sheet1.add("Text", "G"+(x+1));