fix table and table's cells css processing

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1147828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-18 12:25:10 +00:00
parent cacef02b5b
commit 3743efebeb
2 changed files with 25 additions and 5 deletions

View 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() )

View 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;
}
/**