mirror of https://github.com/apache/poi.git
preserve align in case of "divved" cells
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1147941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f86740bfb
commit
b99fd29146
|
@ -161,30 +161,7 @@ public class ExcelToHtmlConverter
|
||||||
StringBuilder style = new StringBuilder();
|
StringBuilder style = new StringBuilder();
|
||||||
|
|
||||||
style.append( "white-space: pre-wrap; " );
|
style.append( "white-space: pre-wrap; " );
|
||||||
|
ExcelToHtmlUtils.appendAlign( style, cellStyle.getAlignment() );
|
||||||
switch ( cellStyle.getAlignment() )
|
|
||||||
{
|
|
||||||
case HSSFCellStyle.ALIGN_CENTER:
|
|
||||||
style.append( "text-align: center; " );
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_CENTER_SELECTION:
|
|
||||||
style.append( "text-align: center; " );
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_FILL:
|
|
||||||
// XXX: shall we support fill?
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_GENERAL:
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_JUSTIFY:
|
|
||||||
style.append( "text-align: justify; " );
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_LEFT:
|
|
||||||
style.append( "text-align: left; " );
|
|
||||||
break;
|
|
||||||
case HSSFCellStyle.ALIGN_RIGHT:
|
|
||||||
style.append( "text-align: right; " );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( cellStyle.getFillPattern() == 0 )
|
if ( cellStyle.getFillPattern() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -486,12 +463,13 @@ public class ExcelToHtmlConverter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean noText = ExcelToHtmlUtils.isEmpty( value );
|
||||||
final short cellStyleIndex = cellStyle.getIndex();
|
final short cellStyleIndex = cellStyle.getIndex();
|
||||||
if ( cellStyleIndex != 0 )
|
if ( cellStyleIndex != 0 )
|
||||||
{
|
{
|
||||||
tableCellElement.setAttribute( "class",
|
tableCellElement.setAttribute( "class",
|
||||||
getStyleClassName( workbook, cellStyle ) );
|
getStyleClassName( workbook, cellStyle ) );
|
||||||
if ( ExcelToHtmlUtils.isEmpty( value ) )
|
if ( noText )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* if cell style is defined (like borders, etc.) but cell text
|
* if cell style is defined (like borders, etc.) but cell text
|
||||||
|
@ -520,7 +498,7 @@ public class ExcelToHtmlConverter
|
||||||
|
|
||||||
Text text = htmlDocumentFacade.createText( value );
|
Text text = htmlDocumentFacade.createText( value );
|
||||||
|
|
||||||
if ( isUseDivsToSpan() )
|
if ( !noText && isUseDivsToSpan() )
|
||||||
{
|
{
|
||||||
tableCellElement.setAttribute( "style",
|
tableCellElement.setAttribute( "style",
|
||||||
"padding:0;margin:0;align:left;vertical-align:top;" );
|
"padding:0;margin:0;align:left;vertical-align:top;" );
|
||||||
|
@ -530,13 +508,22 @@ public class ExcelToHtmlConverter
|
||||||
|
|
||||||
Element innerDiv = htmlDocumentFacade.getDocument().createElement(
|
Element innerDiv = htmlDocumentFacade.getDocument().createElement(
|
||||||
"div" );
|
"div" );
|
||||||
innerDiv.setAttribute( "style", "position:absolute;min-width:"
|
StringBuilder innerDivStyle = new StringBuilder();
|
||||||
+ normalWidthPx
|
innerDivStyle.append( "position:absolute;min-width:" );
|
||||||
+ "px;"
|
innerDivStyle.append( normalWidthPx );
|
||||||
+ ( maxSpannedWidthPx != Integer.MAX_VALUE ? "max-width:"
|
innerDivStyle.append( "px;" );
|
||||||
+ maxSpannedWidthPx + "px;" : "" )
|
if ( maxSpannedWidthPx != Integer.MAX_VALUE )
|
||||||
+ "overflow:hidden;max-height:" + normalHeightPt
|
{
|
||||||
+ "pt;white-space:nowrap;" );
|
innerDivStyle.append( "max-width:" );
|
||||||
|
innerDivStyle.append( maxSpannedWidthPx );
|
||||||
|
innerDivStyle.append( "px;" );
|
||||||
|
}
|
||||||
|
innerDivStyle.append( "overflow:hidden;max-height:" );
|
||||||
|
innerDivStyle.append( normalHeightPt );
|
||||||
|
innerDivStyle.append( "pt;white-space:nowrap;" );
|
||||||
|
ExcelToHtmlUtils.appendAlign( innerDivStyle,
|
||||||
|
cellStyle.getAlignment() );
|
||||||
|
innerDiv.setAttribute( "style", innerDivStyle.toString() );
|
||||||
|
|
||||||
innerDiv.appendChild( text );
|
innerDiv.appendChild( text );
|
||||||
outerDiv.appendChild( innerDiv );
|
outerDiv.appendChild( innerDiv );
|
||||||
|
|
Loading…
Reference in New Issue