我想一个HTML表格转换成文本在垂直方向上与docx4j到DOCX。 这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="ISO-8859-1" />
<title>Platilla HTML para convertirlo a DOCX</title>
<style type="text/css">
body {
font-family:Arial;
font-size:11pt;
}
.titulo {
text-align:center;
font-weight:bold;
}
.contenido {
text-align:justify;
}
.tabla {
width:100%;
border:1px solid black;
border-spacing:0px;
border-collapse:collapse;
margin-top: 10px;
}
.tabla td, .tabla th {
border:1px solid black;
}
.tabla th {
background-color: #898989;
color: white;
text-align: center;
vertical-align: bottom;
height: 150px;
padding-bottom: 3px;
padding-left: 5px;
padding-right: 5px;
}
.verticalText {
text-align: center;
vertical-align: middle;
width: 20px;
margin: 0px;
padding: 0px;
padding-left: 3px;
padding-right: 3px;
padding-top: 10px;
white-space: nowrap;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
};
</style>
</head>
<body>
<table class="tabla">
<tr>
<th><div class="verticalText">No. de Item</div></th>
<th>Departamento / Municipio</th>
<th>Tipo de Servicio</th>
<th>Contratista</th>
<th>Monto maximo</th>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
</table>
</body>
我使用的风格转换的文本垂直方向...
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
......但是当我从HTML与docxj4到DOCX出口(在变量“XHTML”是所有的HTML代码出口)...
private WordprocessingMLPackage export(String xhtml) {
WordprocessingMLPackage wordMLPackage = null;
try {
RFonts arialRFonts = Context.getWmlObjectFactory().createRFonts();
arialRFonts.setAscii("Arial");
arialRFonts.setHAnsi("Arial");
XHTMLImporterImpl.addFontMapping("Arial", arialRFonts);
wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.LETTER, false);
XHTMLImporter importer = new XHTMLImporterImpl(wordMLPackage);
List<Object> content = importer.convert(xhtml, null);
wordMLPackage.getMainDocumentPart().getContent().addAll(content);
} catch (Docx4JException ex) {
Logger.getLogger(ReporteContratoEspecialista.class.getName()).log(Level.SEVERE, null, ex);
}
return wordMLPackage;
}
..保存文档...
wordMLPackage.save(servletOutputStream);
...单元格文本是在正常的方向,水平的,.DOCX文件内。
是否有另一种方式来做到这一点使用HTML生成DOCX文档? 我需要的文本中的docx垂直。