ASF Bugzilla – Attachment 18869 Details for
Bug 40520
HSSFFont.applyFont() formats wrong parts of HSSFRichTextString
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Testcase for the problerm
HSSFRichText.java (text/plain), 2.31 KB, created by
Martin Jost
on 2006-09-15 13:24:05 UTC
(
hide
)
Description:
Testcase for the problerm
Filename:
MIME Type:
Creator:
Martin Jost
Created:
2006-09-15 13:24:05 UTC
Size:
2.31 KB
patch
obsolete
>package poi_hssf; > >import java.io.*; > >import org.apache.poi.hssf.usermodel.*; > > >public class HSSFRichText >{ > private void newRow() > { > this.actRow = this.sheet.createRow(this.nextLineNr); > this.nextLineNr++; > this.actCol = 0; > } > > > private HSSFCell appendCell() > { > this.actCell = this.actRow.createCell(this.actCol++); > return (this.actCell); > } > > > private void test() > { > File file = new File("RichPOI.xls"); > FileOutputStream outStream = null; > try > { > outStream = new FileOutputStream(file); > } > catch (FileNotFoundException e) > { > System.err.println(e.getStackTrace()); > } > > this.wb = new HSSFWorkbook(); > this.sheet = wb.createSheet(); > > HSSFFont font; > font = this.wb.createFont(); > font.setColor((short) 2); // Rot > > HSSFCell cell; > > this.newRow(); > HSSFRichTextString str = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890"); > > // overlapped range => will format whole String > str.applyFont(0,7,font); > str.applyFont(5,9,font); > cell = this.appendCell(); > cell.setCellValue(str); > > > this.newRow(); > HSSFRichTextString str2 = new HSSFRichTextString("f1_123456789012345678901234567890123456789012345678901234567890"); > // formated twice => will format whole String > str2.applyFont(0,2,font); > str2.applyFont(0,2,font); > cell = this.appendCell(); > cell.setCellValue(str2); > > > this.newRow(); > HSSFRichTextString str3 = new HSSFRichTextString("f2_123456789012345678901234567890123456789012345678901234567890"); > // wrong order => will format 0-6 > str3.applyFont(0,2,font); > str3.applyFont(5,7,font); > str3.applyFont(0,2,font); > cell = this.appendCell(); > cell.setCellValue(str3); > > try > { > this.wb.write(outStream); > outStream.close(); > } > catch (IOException e) > { > System.err.println(e.getStackTrace()); > } > } > > > public static void main(String[] args) > { > HSSFRichText testit = new HSSFRichText(); > testit.test(); > } > > > private int nextLineNr; > private short actCol; > private HSSFWorkbook wb; > private HSSFSheet sheet; > private HSSFRow actRow; > private HSSFCell actCell; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 40520
: 18869