Search in sources :

Example 1 with XlsxRowReader

use of net.heartsome.cat.document.xlsx.XlsxRowReader in project translationstudio8 by heartsome.

the class Xlsx2TbxConverter method doConvert.

@Override
public void doConvert(String targetFile, IProgressMonitor monitor) throws Exception {
    try {
        out = new FileOutputStream(new File(targetFile));
        XlsxRowReader reader = new XlsxRowReader(this.xlsxFile, 20, handler);
        try {
            reader.readRows(monitor);
        } catch (ParserConfigurationException e) {
            LOGGER.error("", e);
            throw new Exception(Messages.getString("converter.xlsx2tmx.parseExcle.error"));
        } catch (SAXException e) {
            LOGGER.error("", e);
            if ("LANG-CODE-ERORR".equals(e.getMessage())) {
                throw new Exception(Messages.getString("converter.common.vaild.langcode.error"));
            } else if ("DIFF--SRC-LANG-CODE".equals(e.getMessage())) {
                throw new Exception(Messages.getString("converter.common.appendtmx.diffsrcLang.error"));
            } else if ("EMPTY-LANG-CODE".equals(e.getMessage())) {
                throw new Exception(Messages.getString("converter.common.vaild.langcode.error"));
            } else if ("DUPLICATE-LANG-CODE-ERORR".equals(e.getMessage())) {
                throw new Exception(Messages.getString("converter.common.vaild.duplicatelangcode.error"));
            }
        } catch (IOException e) {
            LOGGER.error("", e);
            throw new Exception(Messages.getString("converter.xlsx2tmx.parseExcle.error"));
        } catch (OpenXML4JException e) {
            LOGGER.error("", e);
            throw new Exception(Messages.getString("converter.xlsx2tmx.parseExcle.error"));
        }
        String s = generateTbxEnd();
        if (s != null && s.length() != 0) {
            writeString(s);
        }
    } catch (FileNotFoundException e) {
        LOGGER.error("", e);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : OpenXML4JException(org.apache.poi.openxml4j.exceptions.OpenXML4JException) FileOutputStream(java.io.FileOutputStream) XlsxRowReader(net.heartsome.cat.document.xlsx.XlsxRowReader) FileNotFoundException(java.io.FileNotFoundException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) File(java.io.File) OpenXML4JException(org.apache.poi.openxml4j.exceptions.OpenXML4JException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SAXException(org.xml.sax.SAXException)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 XlsxRowReader (net.heartsome.cat.document.xlsx.XlsxRowReader)1 OpenXML4JException (org.apache.poi.openxml4j.exceptions.OpenXML4JException)1 SAXException (org.xml.sax.SAXException)1