You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2012/06/20 10:57:38 UTC
svn commit: r1351998 -
/poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java
Author: yegor
Date: Wed Jun 20 08:57:38 2012
New Revision: 1351998
URL: http://svn.apache.org/viewvc?rev=1351998&view=rev
Log:
Utility to test that POI produces readable output after re-saving xls files
Added:
poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java (with props)
Added: poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java
URL: http://svn.apache.org/viewvc/poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java?rev=1351998&view=auto
==============================================================================
--- poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java (added)
+++ poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java Wed Jun 20 08:57:38 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.poi.hssf.dev;
+
+import org.apache.poi.hssf.usermodel.HSSFPatriarch;
+import org.apache.poi.hssf.usermodel.HSSFShape;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+/**
+ * Utility to test that POI produces readable output
+ * after re-saving xls files.
+ *
+ * Usage: ReSave [-dg] input.xls
+ * -dg initialize drawings, causes to re-build escher aggregates in all sheets
+ */
+public class ReSave {
+ public static void main(String[] args) throws Exception {
+ boolean initDrawing = false;
+ for(String arg : args) {
+ if(arg.equals("-dg")) initDrawing = true;
+ else {
+ System.out.print("reading " + arg + "...");
+ FileInputStream is = new FileInputStream(arg);
+ HSSFWorkbook wb = new HSSFWorkbook(is);
+ is.close();
+ System.out.println("done");
+
+ for(int i = 0; i < wb.getNumberOfSheets(); i++){
+ HSSFSheet sheet = wb.getSheetAt(i);
+ if(initDrawing) {
+ HSSFPatriarch dg = sheet.getDrawingPatriarch();
+ }
+ }
+
+ String outputFile = arg.replace(".xls", "-saved.xls");
+ System.out.print("saving to " + outputFile + "...");
+ FileOutputStream out = new FileOutputStream(outputFile);
+ wb.write(out);
+ out.close();
+ System.out.println("done");
+ }
+ }
+ }
+}
Propchange: poi/branches/gsoc2012/src/java/org/apache/poi/hssf/dev/ReSave.java
------------------------------------------------------------------------------
svn:executable = *
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org