IDEMPIERE-5288 org.zkoss.poi.POIXMLException attaching XLSX file (#1320)
This commit is contained in:
parent
603743734d
commit
9bc016dc3d
|
@ -0,0 +1,10 @@
|
||||||
|
-- IDEMPIERE-5288 org.zkoss.poi.POIXMLException attaching XLSX file
|
||||||
|
SELECT register_migration_script('202205101725_IDEMPIERE-5288.sql') FROM dual;
|
||||||
|
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- May 10, 2022, 5:25:40 PM CEST
|
||||||
|
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','<html>There was an error previewing this file.</html>',0,0,'Y',TO_TIMESTAMP('2022-05-10 17:25:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-10 17:25:40','YYYY-MM-DD HH24:MI:SS'),100,200749,'ErrorPreviewingFile','D','67f5c60d-50c0-467b-af04-d46a95555c57')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- IDEMPIERE-5288 org.zkoss.poi.POIXMLException attaching XLSX file
|
||||||
|
SELECT register_migration_script('202205101725_IDEMPIERE-5288.sql') FROM dual;
|
||||||
|
|
||||||
|
-- May 10, 2022, 5:25:40 PM CEST
|
||||||
|
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','<html>There was an error previewing this file.</html>',0,0,'Y',TO_TIMESTAMP('2022-05-10 17:25:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-10 17:25:40','YYYY-MM-DD HH24:MI:SS'),100,200749,'ErrorPreviewingFile','D','67f5c60d-50c0-467b-af04-d46a95555c57')
|
||||||
|
;
|
||||||
|
|
|
@ -495,7 +495,19 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
{
|
{
|
||||||
if (data.length <= maxPreviewSize) {
|
if (data.length <= maxPreviewSize) {
|
||||||
AMedia media = new AMedia(entry.getName(), null, mimeType, entry.getData());
|
AMedia media = new AMedia(entry.getName(), null, mimeType, entry.getData());
|
||||||
customPreviewComponent = view.renderMediaView(previewPanel, media, true);
|
try {
|
||||||
|
customPreviewComponent = view.renderMediaView(previewPanel, media, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warning("Error previewing file in attachment entry " + entry.getName() + " -> " + e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
clearPreview();
|
||||||
|
String msg = WTextEditorDialog.sanitize(Msg.getMsg(Env.getCtx(), "ErrorPreviewingFile"));
|
||||||
|
Media mediaErr = new AMedia(null, null, "text/html", msg.getBytes());
|
||||||
|
preview.setContent(mediaErr);
|
||||||
|
preview.setVisible(true);
|
||||||
|
bPreview.setEnabled(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.idempiere.keikai.view;
|
package org.idempiere.keikai.view;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.idempiere.ui.zk.media.IMediaView;
|
import org.idempiere.ui.zk.media.IMediaView;
|
||||||
import org.zkoss.util.media.AMedia;
|
import org.zkoss.util.media.AMedia;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
@ -68,7 +66,8 @@ public class ExcelMediaView implements IMediaView {
|
||||||
Book book;
|
Book book;
|
||||||
try {
|
try {
|
||||||
book = importer.imports(media.getStreamData(), media.getName());
|
book = importer.imports(media.getStreamData(), media.getName());
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
|
container.removeChild(spreadsheet);
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
spreadsheet.setBook(book);
|
spreadsheet.setBook(book);
|
||||||
|
|
Loading…
Reference in New Issue