I did an ugly hack to try and force the next record be printed and it
worked, but I get some unwelcome results as well.
Here's what I see and what I did:
1) The "if(Double.isNaN( frec.getValue() ))" statement inside the "case
FormulaRecord.sid:" does not properly decode the String formula and as a
result thinks it is a number (0.0 in this case. Because of this
outputNextStringRecord is never set to true and thus the formula is never
printed out in the next iteration.
2) To overcome this, I simply commented out all the logic and forced the
outputNextStringRecord = true to always execute. This now prints out the
String formula, but there are other issues now in that the formatting and
the actual formula is screwed up.
This is what I commented out:
case FormulaRecord.sid:
// Cast record
/// System.out.println("Formula Record");
FormulaRecord frec = (FormulaRecord) record;
thisRow = frec.getRow();
thisColumn = frec.getColumn();
/// if(outputFormulaValues) {
/// if(Double.isNaN( frec.getValue() )) {
// Formula result is a string
// This is stored in the next record
outputNextStringRecord = true;
nextRow = frec.getRow();
nextColumn = frec.getColumn();
/// } else {
/// thisStr = formatListener.formatNumberDateCell(frec);
/// }
/// } else {
/// thisStr = '"' +
/// HSSFFormulaParser.toFormulaString(stubWorkbook,
frec.getParsedExpression()) + '"';
/// }
break;
This is what the result is running the file now:
Sheet1 [1]:
"A","B"
,AB,,,"C"
Sheet2 [2]:
Sheet3 [3]:
As you can see there is a line return after "B". This is because for some
reason the routine now thinks it has reached an end of a row after finding
the formula value????.
There are also two additional ",," before the "C" value.
>From this it definitely looks like there is something broken in the file.
would you be able to comment or point me in the right direction?
Thanks
Des
2008/12/9 Nick Burch <[EMAIL PROTECTED]>
> On Tue, 9 Dec 2008, Des Hartman wrote:
>
>> I am using XLS2CSVmra to parse a very simple XLS file, but I am getting
>> some weird results. It seems the FormulaRecord case is not recognising
>> string formulas.
>>
>
> Unless you have very specific needs, I'd suggest you try the hssf usermodel
> instead. XLS2CSVmra opperates at a very low level, on the records, and is
> exposed to lots of excel oddities. The hssf usermodel hides that sort of
> thing from you
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>