Prev: JMS Message components
Next: Eclipse 3.5.1: "Open Project" dialog pops up when I open a certain class in the Visual Editor
From: Chase Preuninger on 1 Jul 2010 00:40 I am writing an app where I am simply moving cells from one excel file to another. The problem is I need to keep the date formats exactly as they appear in the original. For example "9/12/2005" != "09/12/2005". These dates are not in a consistent format as well. How can I transfer the formats.
From: Lew on 1 Jul 2010 07:12 On 07/01/2010 12:40 AM, Chase Preuninger wrote: > I am writing an app where I am simply moving cells from one excel file > to another. The problem is I need to keep the date formats exactly as > they appear in the original. For example "9/12/2005" != > "09/12/2005". These dates are not in a consistent format as well. > How can I transfer the formats. Make sure the destination CellStyle is the same as that of the source. I'm new to POI myself. -- Lew
From: Chase Preuninger on 2 Jul 2010 01:36 I did that. I called something like cell.getCellStyle().cloneStyleFrom(otherCell.getCellStyle()); It is just very slow so I never go to see if it works.
From: Chase Preuninger on 2 Jul 2010 02:28 Here is my actual code and it still comes across as a number and not a date in the output. newCell.getCellStyle().cloneStyleFrom(currentCell.getCellStyle());
From: John B. Matthews on 2 Jul 2010 19:39
In article <7e1dc5e8-bb3f-4486-abf2-c7128dacd42e(a)k1g2000prl.googlegroups.com>, Chase Preuninger <chasepreuninger(a)gmail.com> wrote: > Here is my actual code and it still comes across as a number and not > a date in the output. > > newCell.getCellStyle().cloneStyleFrom(currentCell.getCellStyle()); I haven't used the cloneStyleFrom() method, but here's a snippet I use to see the format index and string; private static String getFormat(Cell cell) { return " [" + cell.getCellStyle().getDataFormat() + ":" + cell.getCellStyle().getDataFormatString() + "]"; } Also, I see that columns can have separate formats. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> |