cancel
Showing results for 
Search instead for 
Did you mean: 

reg Export to Excel

jnmurthi
Participant
0 Kudos

Hi All,

I have used the Export to Excel component for my application. I have downloaded the componed from SDN. When I use it in my application for opening or saving the table data in an excel file, it is opening in XML list. The actual requirement is that it should get stored as csv file. How can I achieve that?

Can anyone help me regarding this one?

Thank You.

Regards,

Murthy.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi all,

Additionally to the constants defined in class WDWebResourceType (XML, XLS, DOC, etc.), there is a way to export a file to any MIME Type + File Extension combination that exists as a standard.

Instead of using the type constants use the WDWebResourceType.getWebResourceType method:

byte[] fileBytes = ... // the resource bytes you want to export
// MIME Type: "text/csv", File Extension: "csv"
WDWebResourceType type = WDWebResourceType.getWebResourceType("text/csv", "csv");
IWDResource resource = WDWebResourceType.getCachedWebResource(fileBytes, "MyFileName", type);

Finally, you can use the resource to export the file, open in browser, save as dialog, etc.

Please check this link as reference for Mime Types List:

[http://www.webmaster-toolkit.com/mime-types.shtml]

Note. This was tested with SAP NW 7.11.

(The points, please)

Former Member
0 Kudos

Hi

Check the mime type.

and check in the code that the resource type is set to WDWebResourceType XLS

IWDResource createResource(byte[] data, String resourceName,

WDWebResourceType type)

Regards

Ayyapparaj

jnmurthi
Participant
0 Kudos

Thanks for your response.

I will check the code. Can you tell me what are the changes I should do?

Regards,

Murthy.

former_member197348
Active Contributor
0 Kudos

Hi Murthy,

You can not create CSV file using WDWebResourceType.

But you can have work around this by adding ',' after each attribute value.

in exportToExcel2003()

use this

getCachedWebResource(excelXMLFile, fileName, WDWebResourceType.TXT);

in toExcel()

use this

char cm = (char) 44;

for (int i = 0; i < dataNode.size(); i++)

{

IWDNodeElement dataNodeElement = dataNode.getElementAt(i);

for (int m = 0; m < columnInfos.size(); m++)

{

x.append(dataNodeElement.getAttributeValue((String) columnInfos.get(m + ""));

x.append(cm);

}

x.append("\n");

}

return x.toString();

regards,

Siva

jnmurthi
Participant
0 Kudos

Hi Siva,

Thanx for ur response.

I will try this out. As of now I have a problem with the server. I am unable to do any changes in my applications. Once the problem is solved. I shall check this.

Thank You.

Regards,

Murthy.