]> source.dussan.org Git - poi.git/commitdiff
fix table and table's cells css processing
authorSergey Vladimirov <sergey@apache.org>
Mon, 18 Jul 2011 12:25:10 +0000 (12:25 +0000)
committerSergey Vladimirov <sergey@apache.org>
Mon, 18 Jul 2011 12:25:10 +0000 (12:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1147828 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlUtils.java

index 375273d8862c16a98af9a6238b00f17be1784146..751cb30aa5e720df98bebcb8e5c5e350f80c0991 100644 (file)
@@ -219,9 +219,9 @@ public class ExcelToHtmlConverter
             return;
 
         StringBuilder borderStyle = new StringBuilder();
-        borderStyle.append( ExcelToHtmlUtils.getBorderStyle( xlsBorder ) );
-        borderStyle.append( ' ' );
         borderStyle.append( ExcelToHtmlUtils.getBorderWidth( xlsBorder ) );
+        borderStyle.append( ' ' );
+        borderStyle.append( ExcelToHtmlUtils.getBorderStyle( xlsBorder ) );
 
         final HSSFColor color = workbook.getCustomPalette().getColor(
                 borderColor );
@@ -231,7 +231,7 @@ public class ExcelToHtmlConverter
             borderStyle.append( ExcelToHtmlUtils.getColor( color ) );
         }
 
-        style.append( type + "-border: " + borderStyle + "; " );
+        style.append( "border-" + type + ": " + borderStyle + "; " );
     }
 
     void buildStyle_font( HSSFWorkbook workbook, StringBuilder style,
@@ -574,6 +574,8 @@ public class ExcelToHtmlConverter
             return;
 
         Element table = htmlDocumentFacade.createTable();
+        table.setAttribute( "class", "t" );
+
         Element tableBody = htmlDocumentFacade.createTableBody();
 
         final List<Element> emptyRowElements = new ArrayList<Element>(
@@ -648,6 +650,9 @@ public class ExcelToHtmlConverter
             processSheet( workbook, sheet );
         }
 
+        stylesElement
+                .appendChild( htmlDocumentFacade
+                        .createText( "table.t{border-collapse:collapse;border-spacing:0;}\n" ) );
         if ( !cssStyleToClass.isEmpty() )
         {
             for ( Map.Entry<String, String> entry : cssStyleToClass.entrySet() )
index 0131b6f30f2df309eacfbf04cd6fa636ca3476f6..4d64e5fcfee33104cd02ba46b487672b4d2996a0 100644 (file)
@@ -85,7 +85,8 @@ public class ExcelToHtmlUtils
 
     public static String getColor( HSSFColor color )
     {
-        StringBuilder stringBuilder = new StringBuilder();
+        StringBuilder stringBuilder = new StringBuilder( 7 );
+        stringBuilder.append( '#' );
         for ( short s : color.getTriplet() )
         {
             if ( s < 10 )
@@ -93,7 +94,21 @@ public class ExcelToHtmlUtils
 
             stringBuilder.append( Integer.toHexString( s ) );
         }
-        return stringBuilder.toString();
+        String result = stringBuilder.toString();
+
+        if ( result.equals( "#ffffff" ) )
+            return "white";
+
+        if ( result.equals( "#c0c0c0" ) )
+            return "silver";
+
+        if ( result.equals( "#808080" ) )
+            return "gray";
+
+        if ( result.equals( "#000000" ) )
+            return "black";
+
+        return result;
     }
 
     /**