poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1164470 - /poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
Date Fri, 02 Sep 2011 10:53:30 GMT
Author: sergey
Date: Fri Sep  2 10:53:30 2011
New Revision: 1164470

URL: http://svn.apache.org/viewvc?rev=1164470&view=rev
Log:
extract processSheet() method to use with single-sheet processing

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java?rev=1164470&r1=1164469&r2=1164470&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Fri
Sep  2 10:53:30 2011
@@ -716,6 +716,32 @@ public class ExcelToFoConverter extends 
         return tableWidthIn;
     }
 
+    /**
+     * Process single sheet (as specified by 0-based sheet index)
+     * 
+     * @return <tt>true</tt> if result were added to FO document, <tt>false</tt>
+     *         otherwise
+     */
+    protected boolean processSheet( HSSFWorkbook workbook, int sheetIndex )
+    {
+        String pageMasterName = "sheet-" + sheetIndex;
+
+        Element pageSequence = foDocumentFacade
+                .createPageSequence( pageMasterName );
+        Element flow = foDocumentFacade.addFlowToPageSequence( pageSequence,
+                "xsl-region-body" );
+
+        HSSFSheet sheet = workbook.getSheetAt( sheetIndex );
+        float tableWidthIn = processSheet( workbook, sheet, flow );
+
+        if ( tableWidthIn == 0 )
+            return false;
+
+        createPageMaster( tableWidthIn, pageMasterName );
+        foDocumentFacade.addPageSequence( pageSequence );
+        return true;
+    }
+
     protected void processSheetName( HSSFSheet sheet, Element flow )
     {
         Element titleBlock = foDocumentFacade.createBlock();
@@ -752,21 +778,7 @@ public class ExcelToFoConverter extends 
 
         for ( int s = 0; s < workbook.getNumberOfSheets(); s++ )
         {
-            String pageMasterName = "sheet-" + s;
-
-            Element pageSequence = foDocumentFacade
-                    .createPageSequence( pageMasterName );
-            Element flow = foDocumentFacade.addFlowToPageSequence(
-                    pageSequence, "xsl-region-body" );
-
-            HSSFSheet sheet = workbook.getSheetAt( s );
-            float tableWidthIn = processSheet( workbook, sheet, flow );
-
-            if ( tableWidthIn != 0 )
-            {
-                createPageMaster( tableWidthIn, pageMasterName );
-                foDocumentFacade.addPageSequence( pageSequence );
-            }
+            processSheet( workbook, s );
         }
     }
 



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


Mime
View raw message