Create Excel Programmatically | Assetmanager API | Community
Skip to main content
Radha_Krishna_N
Level 3
October 16, 2015
Solved

Create Excel Programmatically | Assetmanager API

  • October 16, 2015
  • 8 replies
  • 3802 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mshaji

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

8 replies

smacdonald2008
Level 10
October 16, 2015

Where are you trying to open the file? 

smacdonald2008
Level 10
October 16, 2015

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 3
October 16, 2015

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

Community Advisor
October 16, 2015

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.

October 16, 2015

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 3
October 16, 2015

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.

MshajiCommunity AdvisorAccepted solution
Community Advisor
October 16, 2015

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

Radha_Krishna_N
Level 3
October 16, 2015

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.