Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Create Excel Programmatically | Assetmanager API

Radha_Krishna_N
Level 4
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
Mshajiahmed
Correct answer by
Level 8
Level 8

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
smacdonald2008
Level 10
Level 10

Where are you trying to open the file? 

smacdonald2008
Level 10
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. 

Radha_Krishna_N
Level 4
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

Mshajiahmed
Level 8
Level 8

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.

prelude07
Level 2
Level 2

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.

Radha_Krishna_N
Level 4
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.

Mshajiahmed
Correct answer by
Level 8
Level 8

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

Radha_Krishna_N
Level 4
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.