on 12-20-2007 12:38 PM
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.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.