本文整理了Java中org.apache.poi.openxml4j.exceptions.InvalidFormatException
类的一些代码示例,展示了InvalidFormatException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InvalidFormatException
类的具体详情如下:
包路径:org.apache.poi.openxml4j.exceptions.InvalidFormatException
类名称:InvalidFormatException
暂无
代码示例来源:origin: org.apache.poi/poi-ooxml
private static ContentType newCorePropertiesPart() {
try {
return new ContentType(ContentTypes.CORE_PROPERTIES_PART);
} catch (InvalidFormatException e) {
// Should never happen
throw new OpenXML4JRuntimeException(
"Package.init() : this exception should never happen, " +
"if you read this message please send a mail to the developers team. : " +
e.getMessage(), e
);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Throws an exception if the specified URI is absolute.
*
* @param partUri
* The URI to check.
* @throws InvalidFormatException
* Throws if the specified URI is absolute.
*/
private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException {
if (partUri.isAbsolute()) {
throw new InvalidFormatException("Absolute URI forbidden: " + partUri);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Set last modification date.
*
* @see org.apache.poi.openxml4j.opc.PackageProperties#setModifiedProperty(java.util.Optional)
*/
public void setModifiedProperty(String modified) {
try {
this.modified = setDateValue(modified);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("modified : "
+ e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Constructor. Parses the content of the specified input stream.
*
* @param in
* If different of <i>null</i> then the content types part is
* retrieve and parse.
* @throws InvalidFormatException
* If the content types part content is not valid.
*/
public ContentTypeManager(InputStream in, OPCPackage pkg)
throws InvalidFormatException {
this.container = pkg;
this.defaultContentType = new TreeMap<>();
if (in != null) {
try {
parseContentTypesFile(in);
} catch (InvalidFormatException e) {
InvalidFormatException ex = new InvalidFormatException("Can't read content types part !");
// here it is useful to add the cause to not loose the original stack-trace
ex.initCause(e);
throw ex;
}
}
}
代码示例来源:origin: wzhe06/ipdatabase
public static Workbook getWorkbook(String filePath){
try {
return WorkbookFactory.create(new FileInputStream(filePath));
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Wrapper to open a package, which works around shortcomings in java's this() constructor calls
*
* @param path the path to the document
* @return the new OPCPackage
*
* @exception IOException if there was a problem opening the document
*/
public static OPCPackage openPackage(String path) throws IOException {
try {
return OPCPackage.open(path);
} catch (InvalidFormatException e) {
throw new IOException(e.toString(), e);
}
}
代码示例来源:origin: zhangdaiscott/jeasypoi
/**
* 读取excel数据
* @param path
*/
public static ArrayList<Map<String,String>> readExcelToObj(String path) {
Workbook wb = null;
ArrayList<Map<String,String>> result = null;
try {
wb = WorkbookFactory.create(new File(path));
result = readExcel(wb, 0, 2, 0);
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Constructor. Parses the content of the specified input stream.
*
* @param in
* If different of <i>null</i> then the content types part is
* retrieve and parse.
* @throws InvalidFormatException
* If the content types part content is not valid.
*/
public ContentTypeManager(InputStream in, OPCPackage pkg)
throws InvalidFormatException {
this.container = pkg;
this.defaultContentType = new TreeMap<>();
if (in != null) {
try {
parseContentTypesFile(in);
} catch (InvalidFormatException e) {
InvalidFormatException ex = new InvalidFormatException("Can't read content types part !");
// here it is useful to add the cause to not loose the original stack-trace
ex.initCause(e);
throw ex;
}
}
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Wrapper to open a package, returning an IOException
* in the event of a problem.
* Works around shortcomings in java's this() constructor calls
*/
public static OPCPackage openPackage(String path) throws IOException {
try {
return OPCPackage.open(path);
} catch (InvalidFormatException e) {
throw new IOException(e.toString());
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Add a marshaller.
*
* @param contentType
* The content type to bind to the specified marshaller.
* @param marshaller
* The marshaller to register with the specified content type.
*/
public void addMarshaller(String contentType, PartMarshaller marshaller) {
try {
partMarshallers.put(new ContentType(contentType), marshaller);
} catch (InvalidFormatException e) {
logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage() + "'. The marshaller will not be added !");
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Throws an exception if the specified part name doesn't start with a
* forward slash character '/'. [M1.4]
*
* @param partUri
* The part name to check.
* @throws InvalidFormatException
* If the specified part name doesn't start with a forward slash
* character '/'.
*/
private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar(
URI partUri) throws InvalidFormatException {
String uriPath = partUri.getPath();
if (uriPath.length() > 0
&& uriPath.charAt(0) != PackagingURIHelper.FORWARD_SLASH_CHAR) {
throw new InvalidFormatException(
"A part name shall start with a forward slash ('/') character [M1.4]: "
+ partUri.getPath());
}
}
代码示例来源:origin: caryyu/excel2pdf
public Excel(InputStream is) {
try {
this.wb = WorkbookFactory.create(is);
this.sheet = wb.getSheetAt(wb.getActiveSheetIndex());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Set last printed date.
*
* @see org.apache.poi.openxml4j.opc.PackageProperties#setLastPrintedProperty(java.util.Optional)
*/
public void setLastPrintedProperty(String lastPrinted) {
try {
this.lastPrinted = setDateValue(lastPrinted);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("lastPrinted : "
+ e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Wrapper to open a package, which works around shortcomings in java's this() constructor calls
*
* @param path the path to the document
* @return the new OPCPackage
*
* @exception IOException if there was a problem opening the document
*/
public static OPCPackage openPackage(String path) throws IOException {
try {
return OPCPackage.open(path);
} catch (InvalidFormatException e) {
throw new IOException(e.toString(), e);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Add an unmarshaller.
*
* @param contentType
* The content type to bind to the specified unmarshaller.
* @param unmarshaller
* The unmarshaller to register with the specified content type.
*/
public void addUnmarshaller(String contentType,
PartUnmarshaller unmarshaller) {
try {
partUnmarshallers.put(new ContentType(contentType), unmarshaller);
} catch (InvalidFormatException e) {
logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage()
+ "'. The unmarshaller will not be added !");
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Throws an exception if the specified part name ends with a forwar slash
* character '/'. [M1.5]
*
* @param partUri
* The part name to check.
* @throws InvalidFormatException
* If the specified part name ends with a forwar slash character
* '/'.
*/
private static void throwExceptionIfPartNameEndsWithForwardSlashChar(
URI partUri) throws InvalidFormatException {
String uriPath = partUri.getPath();
if (uriPath.length() > 0
&& uriPath.charAt(uriPath.length() - 1) == PackagingURIHelper.FORWARD_SLASH_CHAR) {
throw new InvalidFormatException(
"A part name shall not have a forward slash as the last character [M1.5]: "
+ partUri.getPath());
}
}
代码示例来源:origin: hmkcode/Java
wb = WorkbookFactory.create(new File("workbook.xlsx"));
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Set last modification date.
*
* @see org.apache.poi.openxml4j.opc.PackageProperties#setModifiedProperty(java.util.Optional)
*/
public void setModifiedProperty(String modified) {
try {
this.modified = setDateValue(modified);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("modified : "
+ e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
throw new InvalidOperationException(e.getMessage());
throw new InvalidOperationException(e.getMessage());
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public boolean load(InputStream ios) throws InvalidFormatException {
// Grab the data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
IOUtils.copy(ios, baos);
} catch(IOException e) {
throw new InvalidFormatException(e.getMessage());
}
// Save it
data = baos.toByteArray();
// All done
return true;
}
内容来源于网络,如有侵权,请联系作者删除!