on 02-14-2009 10:47 AM
hi Experts,
I am trying to download an excel sheet from the webdynpro application. I have created filedownload element in the webdynpro application.
and written the below code.
String pathXLS = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"ABC.xls");
InputStream streamXLS = new FileInputStream(pathXLS);
IWDResource LocalConveyanceResourceXLS = WDResourceFactory.createResource(stream, "ABC.xls", WDWebResourceType.XLS, true);
wdContext.currentContextElement().setLocalConveyanceResourceTargetXLS(LocalConveyanceResourceXLS);
I am able to download an excel sheet but it is blank with no data inside ?
Points would be given to helpful answers.
Regards,
Sanjyoti.
Hi,
Check this blog:
/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
try this Code it will read the complete excel file and populate data in to Context Node.
wdContext.nodeUsersFromFileDataNode().invalidate();
IPrivateUserDataView.IUploadFileInformationElement element = wdContext.currentUploadFileInformationElement();
if (element.getFileResource() != null)
{
IWDResource resource = element.getFileResource();
if (resource.getResourceType().getFileExtension().equals("xls"))
{
wdContext.currentUploadFileInformationElement().setFileInformationVisibility(WDVisibility.VISIBLE);
wdContext.currentUploadFileInformationElement().setIsBulkOperation(true);
wdContext.currentUploadFileInformationElement().setFileName("File Name : " + resource.getResourceName());
wdContext.currentUploadFileInformationElement().setFileSize("File Size : " + getFileSize(resource));
try
{
InputStream inputStream = resource.read(false);
Workbook workbook = Workbook.getWorkbook(inputStream);
Sheet sheet = workbook.getSheet(0);
int number_user = sheet.getRows() - 1;
wdContext.currentUploadFileInformationElement().setNumberOfUser("Number of User : " + number_user);
for (int i = 1; i < sheet.getRows(); i++)
{
IPrivateUserDataView.IUsersFromFileDataNodeElement userElement = wdContext.createUsersFromFileDataNodeElement();
parseFileData(i, sheet, userElement);
}
workbook.close();
} catch (Exception ex)
{
}
} else
{
wdComponentAPI.getMessageManager().reportWarning("Please select valid file type.");
}
}
//@@end
}
For Parsing the data : parseFileData(i, sheet, userElement);
for (int i = 0; i < sheet.getColumns(); i++)
{
if (i == 0)
userElement.setUserId(sheet.getCell(0, row).getContents());
if (i == 1)
userElement.setPassword(sheet.getCell(1, row).getContents());
if (i == 2)
userElement.setLastName(sheet.getCell(2, row).getContents());
if (i == 3)
userElement.setFirstName(sheet.getCell(3, row).getContents());
if (i == 4)
userElement.setPhone(sheet.getCell(4, row).getContents());
if (i == 5)
userElement.setFax(sheet.getCell(5, row).getContents());
if (i == 6)
userElement.setEmail(sheet.getCell(6, row).getContents());
}
wdContext.nodeUsersFromFileDataNode().addElement(userElement);
wdContext.nodeUsersFromFileDataNode().setLeadSelection(-1);
Hope it will help you
Best Regards
Satish Kumar
Hi,
May be of use for you
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 Sanjyoti,
Check the below link , it will be helpful . It gives you step step procedure on how to download data into a excel sheet with snapshots ,
https://www.sdn.sap.com/irj/scn/wiki?path=/x/0mq
Regards,
Sam Charles J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
7 | |
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.