poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Javen O'Neal" <javenon...@gmail.com>
Subject Re: Copy cell with validation
Date Tue, 06 Oct 2015 14:56:32 GMT
Please check out the patch I have in the queue for bug 58348 comment 4 [1].
I don't think my implementation copies data validation or conditional
formating, but this would be the place to add it.

[1]
https://bz.apache.org/bugzilla/attachment.cgi?id=33138&action=diff#src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java_sec5
On 6 Oct 2015 06:36, "Bengt Rodehav" <bengt@rodehav.com> wrote:

> I have template sheets that I use to copy cells with formatting to other
> sheets. I do it this way:
>
>   private static void copyCell(Cell oldCell, Cell newCell) {
>     newCell.setCellStyle(oldCell.getCellStyle());
>
>     switch (oldCell.getCellType()) {
>     case Cell.CELL_TYPE_STRING:
>       newCell.setCellValue(oldCell.getRichStringCellValue());
>       break;
>     case Cell.CELL_TYPE_NUMERIC:
>       newCell.setCellValue(oldCell.getNumericCellValue());
>       break;
>     case Cell.CELL_TYPE_BLANK:
>       newCell.setCellType(Cell.CELL_TYPE_BLANK);
>       break;
>     case Cell.CELL_TYPE_FORMULA:
>       newCell.setCellFormula(oldCell.getCellFormula());
>       break;
>     case Cell.CELL_TYPE_BOOLEAN:
>       newCell.setCellValue(oldCell.getBooleanCellValue());
>       break;
>     case Cell.CELL_TYPE_ERROR:
>       newCell.setCellErrorValue(oldCell.getErrorCellValue());
>       break;
>     default:
>       break;
>     }
>   }
>
> This seems to work and since I use the same style, the formatting is copied
> as well.
>
> However, some of the cells have data validations that renders as a listbox.
> How can I copy the data validation from one cell to another? If the source
> cell has a listbox I want the target cell to have one too.
>
> /Bengt
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message