コード例 #1
0
ファイル: SheetWriter.java プロジェクト: qiang2100/Smoker
  /** Writes out the data validations */
  private void writeDataValidation() throws IOException {
    if (dataValidation != null && validatedCells.size() == 0) {
      // only data validations are those read in
      dataValidation.write(outputFile);
      return;
    }

    if (dataValidation == null && validatedCells.size() > 0) {
      int comboBoxId =
          sheet.getComboBox() != null
              ? sheet.getComboBox().getObjectId()
              : DataValidation.DEFAULT_OBJECT_ID;
      dataValidation =
          new DataValidation(
              comboBoxId, sheet.getWorkbook(), sheet.getWorkbook(), workbookSettings);

      for (Iterator i = validatedCells.iterator(); i.hasNext(); ) {
        CellValue cv = (CellValue) i.next();
        CellFeatures cf = cv.getCellFeatures();
        DataValiditySettingsRecord dvsr = new DataValiditySettingsRecord(cf.getDVParser());
        dataValidation.add(dvsr);
      }
      dataValidation.write(outputFile);
      return;
    }

    // Read and write validations
    for (Iterator i = validatedCells.iterator(); i.hasNext(); ) {
      CellValue cv = (CellValue) i.next();
      CellFeatures cf = cv.getCellFeatures();
      DataValiditySettingsRecord dvsr = new DataValiditySettingsRecord(cf.getDVParser());
      dataValidation.add(dvsr);
    }
    dataValidation.write(outputFile);
    return;
  }