https://issues.apache.org/bugzilla/show_bug.cgi?id=30311
--- Comment #14 from Josh Micich <[EMAIL PROTECTED]> 2008-04-07 16:15:34 PST
---
Dmitriy,
Looks like everything is mostly OK now. Perhaps we should consider this
bugzilla closed since this is a good milestone - POI now seems to support quite
a few simple Conditional Formatting use-cases. Any future bugs related to
Conditional Formatting should probably get their own specific bugzilla.
(In reply to comment #13)
> ... What are the POI's conventions for file creation? ...
See methods at the top of hssf.usermodel.TestBugs. The least preferred action
is to create an XLS file that requires a developer to open and inspect - mostly
because that operation is expensive. Usually the only person that can properly
judge success is the one who originally wrote the junit.
So - try to write tests that unambiguously detect bug conditions with plain
java code. For example, if you find that setting
CFHeaderRecord.field_1_numcf=-1 causes excel to crash, write a junit that
confirms POI does not do this, and put a comment on it explaining why this is
important.
This approach requires does more work though, because it involves a little bit
of reverse engineering: "What exactly does my bug-fix change about the output
XLS file that causes it to open OK in Excel?"
---------------
> ... I did try to create a file and it worked fine for me...
I found the old test which gave me trouble and re-ran it, and things are much
better now. I also re-ran as-of svn revision 642878, but the bold format seems
to get lost. So you must have fixed something regarding font formatting since
then.
The original (more serious bug) was that Excel would complain when opening the
file, and (un)fortunately I couldn't reproduce that. I must have inadvertently
fixed that while completing the work for 642878.
I attached the sample code below for you to take a look at. Note that it still
shows a difference in the 118 byte font format data. Is that a problem? Your
call.
The input file (cfEx.xls) for this test is a file created by Excel with one
conditional format entry. The only format is font-type: bold, so the sample
code should ideally change nothing
--
InputStream is = new FileInputStream("cfEx.xls");
HSSFWorkbook wb = new HSSFWorkbook(is);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(0);
Region[] regions = cf.getFormattingRegions();
sheet.removeConditionalFormatting(0);
HSSFFontFormatting fontFmt = new HSSFFontFormatting();
fontFmt.setFontStyle(false, true);
byte op = CFRuleRecord.ComparisonOperator.BETWEEN;
HSSFConditionalFormattingRule rule = sheet.createConditionalFormattingRule(op,
"5", "10", fontFmt, null, null);
HSSFConditionalFormattingRule rule1 = cf.getRule(0);
byte[] rawRecord1 = rule1.getCfRuleRecord().getFontFormatting().getRawRecord();
for (int i = 0; i < rawRecord1.length; i++) {
System.out.print(rawRecord1[i] + ",");
}
System.out.println();
byte[] rawRecord = fontFmt.getFontFormattingBlock().getRawRecord();
for (int i = 0; i < rawRecord.length; i++) {
System.out.print(rawRecord[i]+ ",");
}
System.out.println();
sheet.addConditionalFormatting(regions, new HSSFConditionalFormattingRule[] {
rule, });
OutputStream os = new FileOutputStream("cfEx-out.xls");
wb.write(os);
os.close();
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]