use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class SheetPart method getCells.
public List<Cell> getCells(String dataType) throws InternalFileException {
cellList = new ArrayList<Cell>();
String xpath = "/worksheet/sheetData/row/c[@t='" + dataType + "']";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
try {
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
Hashtable<String, String> attrs = vu.getCurrentElementAttributs();
SpreadsheetUtil.assertNull(attrs);
String styleIndex = attrs.get("s");
styleIndex = styleIndex == null ? "-1" : styleIndex;
String val = vu.getChildContent("v");
val = val == null ? "" : val;
Cell cell = new Cell(val, Integer.parseInt(styleIndex), dataType);
cellList.add(cell);
}
} catch (VTDException e) {
logger.error("", e);
}
return cellList;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class SheetPart method loadDrawingsPart.
private void loadDrawingsPart() throws InternalFileException {
String xpath = "/worksheet/drawing";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
try {
ap.selectXPath(xpath);
if (ap.evalXPath() != -1) {
Hashtable<String, String> attrs = vu.getCurrentElementAttributs();
SpreadsheetUtil.assertNull(attrs);
String rId = attrs.get("r:id");
Relationship r = relsPart.getRelationshipById(rId);
SpreadsheetUtil.assertNull(r);
SpreadsheetDocument.spreadsheetPackage.markRoot();
try {
this.drawingsPart = new DrawingsPart(r.getTarget());
} catch (FileNotFoundException e) {
// no drawingsPart
}
SpreadsheetDocument.spreadsheetPackage.resetRoot();
}
} catch (VTDException e) {
logger.error("", e);
}
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class StylesPart method isRedColor.
/**
* 加载红前景色样式
*/
private boolean isRedColor(int idx) {
idx += 1;
String xpath = "/styleSheet/fonts/font[" + idx + "]";
try {
vu.getVTDNav().push();
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
String rgb = vu.getElementAttribute("./color", "rgb");
if (rgb != null && rgb.equals("FFFF0000")) {
return true;
}
}
vu.getVTDNav().pop();
} catch (VTDException e) {
e.printStackTrace();
}
return false;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class WorkBookPart method loadWorkSheets.
private void loadWorkSheets() throws InternalFileException, FileNotFoundException {
sheetPartList = new ArrayList<SheetPart>();
int ssiIndex = 0;
StringBuffer siBf = new StringBuffer();
try {
String xpath = "/workbook/sheets/sheet";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
int index = vu.getVTDNav().getAttrVal("name");
if (index == -1) {
throw new InternalFileException(Messages.getString("msexcel.converter.exception.msg1"));
}
String name = vu.getVTDNav().toRawString(index);
index = vu.getVTDNav().getAttrVal("sheetId");
if (index == -1) {
throw new InternalFileException(Messages.getString("msexcel.converter.exception.msg1"));
}
String id = vu.getVTDNav().toRawString(index);
index = vu.getVTDNav().getAttrVal("r:id");
if (index == -1) {
throw new InternalFileException(Messages.getString("msexcel.converter.exception.msg1"));
}
String rid = vu.getVTDNav().toRawString(index);
Relationship r = relsPart.getRelationshipById(rid);
SpreadsheetUtil.assertNull(r);
String target = r.getTarget();
SheetPart sp = new SheetPart(name, id, target);
ssiIndex = sp.fillShareStringTable(sst, ssiIndex, siBf);
sheetPartList.add(sp);
}
// fix bug Bug #2925 转换excel文件--空指针异常,转换失败 by jason
if (sst != null && siBf.length() != 0) {
sst.updateShareStringTable(siBf.toString());
}
} catch (VTDException e) {
logger.error("", e);
} catch (IOException e) {
}
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class AbstractDrawing method getDeclareNSAutoPilot.
/**
* 获取带有命名空间申明的AtutoPilot对象
* @return ;
*/
protected AutoPilot getDeclareNSAutoPilot() {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.declareXPathNameSpace(Constants.NAMESPACE_DRAWING_PREFIX_XDR, Constants.NAMESPACE_DRAWING_URL_XDR);
ap.declareXPathNameSpace(Constants.NAMESPACE_DRAWING_PREFIX_A, Constants.NAMESPACE_DRAWING_URL_A);
return ap;
}
Aggregations