Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Create Excel Programmatically | Assetmanager API

Avatar

Level 4

Hi,

I have HSSFWorkbook Object using wich I have to create an excel file in /content/dam.

//code snippet

InputStream is = new ByteArrayInputStream(workbook.getBytes());

AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);     

 assetManager.createAsset("/content/dam/test-report.xls", is, "application/vnd.ms-excel", true);

 

the above lines creating the excel file,but I am unable to open the file. 

how to resolve this issue?

 

Thanks,

Radhakrishna N

1 Accepted Solution

Avatar

Correct answer by
Level 9

Here is the problem

com.day.cq.dam.core.process.CommandLineProcess execute: mime type [application/vnd.ms-excel] of asset [/content/dam/report.xls] is not in list of accepted mime types [[image/eps, image/x-eps, application/postscript, application/eps, application/x-eps]], ignoring.

it is not finding the mimetype

Go to felix console configuration

OSGI -> Configuration -> Apache Sling MIME Type Service

Add the mimetype application/vnd.ms-excel

and try again

View solution in original post

8 Replies

Avatar

Level 10

Where are you trying to open the file? 

Avatar

Level 10

When you upload an Excel file to AEM, you can see it in the DAM, as shown here: 

[img]Excel.png[/img]

You can download the excel file,

The DAM is a repository to store the file - but you cannot open and view the excel data in AEM. 

Avatar

Level 4

I created the excel using AssetManager API. Downloaded the file from DAM admin console. but I am unable to open the file.

I have attached the downloaded excel file.

Thanks,

Radhakrishna N

Avatar

Level 9

Have you tried creating file using any other format like pdf, csv, just to see whether they have the same problem.

When it creates the file please look into error.log for any errors.

Avatar

Former Community Member

Radha Krishna.N wrote...

I created the excel using AssetManager API. Downloaded the file from DAM admin console. but I am unable to open the file.

I have attached the downloaded excel file.

Thanks,

Radhakrishna N

I was able to download and open it - You just can't view it in AEM.

Avatar

Level 4

tried with csv extension, facing the same issue. 

when I write the file to filesystem and try to open, it is opening!!

but when I write to CRX, then download from DAM console and try to open, it is not.

Also, We have updated Update Asset workflow to exclude Assets other than Image files. Is this causing the issue?

I have attached part of log file generated when excel file created in AEM.

Avatar

Correct answer by
Level 9

Here is the problem

com.day.cq.dam.core.process.CommandLineProcess execute: mime type [application/vnd.ms-excel] of asset [/content/dam/report.xls] is not in list of accepted mime types [[image/eps, image/x-eps, application/postscript, application/eps, application/x-eps]], ignoring.

it is not finding the mimetype

Go to felix console configuration

OSGI -> Configuration -> Apache Sling MIME Type Service

Add the mimetype application/vnd.ms-excel

and try again

Avatar

Level 4

Issue I am facing only when I create the excel file and download and try to open.

but If I upload any other existing excel using dam console and download the same file and try to open, it is opening.

I did not add any mime type in OSGI config, though.