You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Karl-Heinz Zengerle <ka...@sawag.com> on 2004/04/21 18:34:38 UTC

how to force to be a string cell

Hi world.
 
In some cases we explicitly store things as strings. At the moment wenn
the cell value is set we see the value correct. But when we open Excel
afterwards we see 04.03.2004 where we have set "03/04-4".
 
Even additional forcing with e.g.
            HSSFCellStyle oCS =
this.oiShXl.getOiWBXl().getOiWBP().createCellStyle();
            oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));
// text
doesn't help.
 
Because of the implicit conversion our original input is lost.
 
As a date value might be derived from several external representation
(and thus that implicit conversions aren't a bijective function in the
mathematical sense) this can't be corrected in a general manner by Excel
macros.
 
How can we force that the things remain strings???
 
A further trial was prefixing with a prime (') but this also didn't work
well and brought other problems.
 
In another application we copy a string from one cell to another
(normally empty one) via
 
      String sTmp = oCellP.getStringCellValue();
      oCellPT.setCellValue(sTmp);
 
There with the same data ("03/04-4") we don't have such problems.
 
Regards,
Karl-Heinz Zengerle
 

AW: how to force to be a string cell

Posted by Karl-Heinz Zengerle <ka...@sawag.com>.
Hi world.

Somehow it's depending on the template.

Using templates where cells have to be created instead of updated the
things work well.
Using templates where cells are overwritten (even if we explicitly want
to write the things as strings) Excel is so stubborn that the old
formatting is still influencing in a bad way.

Does anybody have an idea how to force Excel to forget such old things?

Not having to mind about the history of an Excel file (what happened
before; just emptying some cells for using it as a template) is much
easier to maintain. (Keep It Simple and Straight.)

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Karl-Heinz Zengerle [mailto:karl-heinz.zengerle@sawag.com] 
Gesendet: Mittwoch, 21. April 2004 18:41
An: 'POI Users List'
Betreff: AW: how to force to be a string cell

Hi world.

At an other place we store "1.2" and it's implicitly converted to 1,2.
In another cell referencing this via a formula it's even a datetime.

That things shall be strings and nothing else and they're stored as
strings.

How can that ugly side effects be suppressed?

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Karl-Heinz Zengerle [mailto:karl-heinz.zengerle@sawag.com] 
Gesendet: Mittwoch, 21. April 2004 18:35
An: poi-user@jakarta.apache.org
Betreff: how to force to be a string cell

Hi world.
 
In some cases we explicitly store things as strings. At the moment wenn
the cell value is set we see the value correct. But when we open Excel
afterwards we see 04.03.2004 where we have set "03/04-4".
 
Even additional forcing with e.g.
            HSSFCellStyle oCS =
this.oiShXl.getOiWBXl().getOiWBP().createCellStyle();
            oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));
// text
doesn't help.
 
Because of the implicit conversion our original input is lost.
 
As a date value might be derived from several external representation
(and thus that implicit conversions aren't a bijective function in the
mathematical sense) this can't be corrected in a general manner by Excel
macros.
 
How can we force that the things remain strings???
 
A further trial was prefixing with a prime (') but this also didn't work
well and brought other problems.
 
In another application we copy a string from one cell to another
(normally empty one) via
 
      String sTmp = oCellP.getStringCellValue();
      oCellPT.setCellValue(sTmp);
 
There with the same data ("03/04-4") we don't have such problems.
 
Regards,
Karl-Heinz Zengerle
 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


AW: how to force to be a string cell

Posted by Karl-Heinz Zengerle <ka...@sawag.com>.
Hi world.

At an other place we store "1.2" and it's implicitly converted to 1,2.
In another cell referencing this via a formula it's even a datetime.

That things shall be strings and nothing else and they're stored as
strings.

How can that ugly side effects be suppressed?

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Karl-Heinz Zengerle [mailto:karl-heinz.zengerle@sawag.com] 
Gesendet: Mittwoch, 21. April 2004 18:35
An: poi-user@jakarta.apache.org
Betreff: how to force to be a string cell

Hi world.
 
In some cases we explicitly store things as strings. At the moment wenn
the cell value is set we see the value correct. But when we open Excel
afterwards we see 04.03.2004 where we have set "03/04-4".
 
Even additional forcing with e.g.
            HSSFCellStyle oCS =
this.oiShXl.getOiWBXl().getOiWBP().createCellStyle();
            oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));
// text
doesn't help.
 
Because of the implicit conversion our original input is lost.
 
As a date value might be derived from several external representation
(and thus that implicit conversions aren't a bijective function in the
mathematical sense) this can't be corrected in a general manner by Excel
macros.
 
How can we force that the things remain strings???
 
A further trial was prefixing with a prime (') but this also didn't work
well and brought other problems.
 
In another application we copy a string from one cell to another
(normally empty one) via
 
      String sTmp = oCellP.getStringCellValue();
      oCellPT.setCellValue(sTmp);
 
There with the same data ("03/04-4") we don't have such problems.
 
Regards,
Karl-Heinz Zengerle
 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


AW: how to force to be a string cell

Posted by Karl-Heinz Zengerle <ka...@sawag.com>.
Hi world.

Excel made the problems. We run macros at the next startup and there it
was obvious. So from POI nothing is influencable.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Karl-Heinz Zengerle [mailto:karl-heinz.zengerle@sawag.com] 
Gesendet: Mittwoch, 21. April 2004 18:35
An: poi-user@jakarta.apache.org
Betreff: how to force to be a string cell

Hi world.
 
In some cases we explicitly store things as strings. At the moment wenn
the cell value is set we see the value correct. But when we open Excel
afterwards we see 04.03.2004 where we have set "03/04-4".
 
Even additional forcing with e.g.
            HSSFCellStyle oCS =
this.oiShXl.getOiWBXl().getOiWBP().createCellStyle();
            oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));
// text
doesn't help.
 
Because of the implicit conversion our original input is lost.
 
As a date value might be derived from several external representation
(and thus that implicit conversions aren't a bijective function in the
mathematical sense) this can't be corrected in a general manner by Excel
macros.
 
How can we force that the things remain strings???
 
A further trial was prefixing with a prime (') but this also didn't work
well and brought other problems.
 
In another application we copy a string from one cell to another
(normally empty one) via
 
      String sTmp = oCellP.getStringCellValue();
      oCellPT.setCellValue(sTmp);
 
There with the same data ("03/04-4") we don't have such problems.
 
Regards,
Karl-Heinz Zengerle
 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org