cancel
Showing results for 
Search instead for 
Did you mean: 

Export to excel in CE : Issue with getPublicCachedWebResource

Former Member
0 Kudos

Hi Friends,

I am trying to export table data to excel. I have considered the related posts in SDN. The pproblem I am facing is due to the NWDS version I guess. I a using CE7.1 SP05.

My code is :

cachedWebResource = WDWebResource.getPublicCachedWebResource(excelCSVFile, type, WDScopeType.APPLICATION_SCOPE,

wdThis

.wdGetAPI()

.getComponent()

.getDeployableObjectPart(),

fileName);

wdComponentAPI.getMessageManager().reportSuccess("Resource Name " + cachedWebResource.getURL());

The output is :

../../../../webdynpro/resources/demo.sap.com/jxltest/Components/com.sap.demo.jxltest.jxltestapp.comp.JxltestappComp/output81389.xls

I have no idea where from the number 81389 is appending after output. The file should be "output.xls". This is different everytime I run the program.

Need help. Any pointer will be appreciated.

Thanks,

Mickey.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Resolved the issue.

Former Member
0 Kudos

Hi,

Just for Info: In the documentation mentioned that the last parameter is key/name. So i guess it is generating an unique key every time and appending to name.

How are you giving the file name. Are you giving as "ouput.xls". If yes anyway we are specifying the resource type as xls. So please check by giving the file name as only "output".

Regards,

Charan

Former Member
0 Kudos

Charan,

I have tried giving output only, in that case its giving error as root element for xls not specified.

I have followed the steps correctly as specified in blogs and help.

The key appended at end is not allowing to open the correct xls file as well.

Regards,

Mickey.

Former Member
0 Kudos

Thanks everyone. I resolved this issue. The below code worked for me.

IWDResource cachedExcelResource = getCachedWebResource(excelCSVFile, "output.xls", WDWebResourceType.getWebResourceType("application/ms-excel", "xls"));

The method getCachedWebResource() :

private IWDResource getCachedWebResource(FileInputStream excelCSVFile, String fileName, WDWebResourceType type) {

IWDResource cachedWebResource = null;

if (excelCSVFile != null)

{

cachedWebResource = WDResourceFactory.createCachedResource(excelCSVFile, fileName, type, false);

}

return cachedWebResource;

}

Former Member
0 Kudos

hi

check this thread

Thanks

Former Member
0 Kudos

Hi,

Refer this link, step by step procedure is there,

/docs/DOC-8061#58 [original link is broken]

Regards,

Sunaina Reddy T

former_member192434
Active Contributor
0 Kudos

HI

Are you creating content Excel file name.....before exoprting to excel as i meintioned in below code.....this code is running on my system.

java.io.File f = new java.io.File("output.xls");

WritableWorkbook workbook = Workbook.createWorkbook(f);

WritableFont red = new WritableFont(WritableFont.ARIAL,

WritableFont.DEFAULT_POINT_SIZE,

WritableFont.BOLD,

false,

UnderlineStyle.SINGLE,

Colour.DARK_BLUE);

WritableCellFormat redFormat = new WritableCellFormat(red);

WritableFont blue = new WritableFont(WritableFont.ARIAL,

WritableFont.DEFAULT_POINT_SIZE,

WritableFont.NO_BOLD,

false,

UnderlineStyle.NO_UNDERLINE,

Colour.BLACK);

WritableCellFormat blueFormat = new WritableCellFormat(blue);

WritableSheet sheet = workbook.createSheet("First Sheet", 0);