Search in sources :

Example 1 with WorkBookPart

use of net.heartsome.cat.converter.msexcel2007.document.WorkBookPart in project translationstudio8 by heartsome.

the class XliffReader method read2SpreadsheetDoc.

public void read2SpreadsheetDoc(String spreadsheetDocFile, String xliffFile, String sklFile, IProgressMonitor monitor) throws InternalFileException {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask(Messages.getString("msexcel.xliff2mse.task1"), 5);
    loadFile(xliffFile);
    monitor.worked(1);
    monitor.setTaskName(Messages.getString("msexcel.xliff2mse.task2"));
    try {
        SpreadsheetDocument.open(sklFile);
        monitor.worked(1);
        WorkBookPart wb = SpreadsheetDocument.workBookPart;
        List<SheetPart> sheetList = wb.getSheetParts();
        readSheet(sheetList, new SubProgressMonitor(monitor, 1));
        monitor.setTaskName(Messages.getString("msexcel.xliff2mse.task3"));
        wb.save();
        monitor.worked(1);
        try {
            ZipUtil.zipFolder(spreadsheetDocFile, SpreadsheetDocument.spreadsheetPackage.getPackageSuperRoot());
        } catch (IOException e) {
            logger.error("", e);
        }
        monitor.worked(1);
    } finally {
        SpreadsheetDocument.close();
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkBookPart(net.heartsome.cat.converter.msexcel2007.document.WorkBookPart) SheetPart(net.heartsome.cat.converter.msexcel2007.document.SheetPart) IOException(java.io.IOException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 2 with WorkBookPart

use of net.heartsome.cat.converter.msexcel2007.document.WorkBookPart in project translationstudio8 by heartsome.

the class SpreadsheetReader method read2XliffFile.

/**
	 * 将内容读入到XLIFF文件
	 * @param xlfOs
	 *            XLIFF文件BufferWriter
	 * @param filterRedCell
	 *            是否需要过滤标记为红色的单元格
	 * @param monitor
	 * @throws InternalFileException
	 * @throws IOException
	 *             ;
	 */
public void read2XliffFile(String inputFile, BufferedWriter xlfOs, String sklFilePath, boolean filterRedCell, IProgressMonitor monitor) throws InternalFileException, IOException {
    this.xlfOs = xlfOs;
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask("", 5);
    try {
        monitor.setTaskName(Messages.getString("msexcel.mse2xliff.task2"));
        // open source file
        SpreadsheetDocument.open(inputFile);
        monitor.worked(1);
        monitor.setTaskName(Messages.getString("msexcel.mse2xliff.task3"));
        // load current workbook
        WorkBookPart wb = SpreadsheetDocument.workBookPart;
        if (filterRedCell) {
            this.filterStyleIndex = wb.getStylesPart().getFilterCellStyle();
        }
        // read worksheet
        List<SheetPart> sheetList = wb.getSheetParts();
        readSheets(sheetList, new SubProgressMonitor(monitor, 2));
        // save current document
        wb.save();
        monitor.worked(1);
        monitor.setTaskName(Messages.getString("msexcel.mse2xliff.task4"));
        // generate skl file
        saveSklFile(sklFilePath);
        monitor.worked(1);
    } finally {
        SpreadsheetDocument.close();
    }
    monitor.done();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkBookPart(net.heartsome.cat.converter.msexcel2007.document.WorkBookPart) SheetPart(net.heartsome.cat.converter.msexcel2007.document.SheetPart) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

SheetPart (net.heartsome.cat.converter.msexcel2007.document.SheetPart)2 WorkBookPart (net.heartsome.cat.converter.msexcel2007.document.WorkBookPart)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 IOException (java.io.IOException)1