on 09-26-2013 10:50 AM
Hi Guys,
I have a requirement where in i want to seperate the excel sheets based on the different projects. Say first 3 similar projects in 1 sheet and another set of projects in another sheets. Currently I am using HTML Tags API and not JXL.Jar file . Can some one please let me know the code for it to seperate the sheets based on the project differentiation.
Any help would be highly appreciated.
I think you really should (re-)read the file upload/download documents thoroughly, and then you will understand why your code won't work;
So,
Hope this helps your understanding 🙂
Best regards,
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please share the name of the api used to build excel?
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You mean separate the sheets?
Workbook excelWB = Workbook.getWorkbook(wdContext.currentContextElement().getExcelResource().read(true)); | ||
Sheet excelSheet = excelWB.getSheet(0);// Get the first sheet of the excel Sheet excelSheet2 = excelWB.getSheet(1); and so on for otother sheets. Regards, Sharath |
This is What i have written and am not ggetting the local path of the file to be sent to the backend and its coming as the application server path.
IPrivateUploadCompView.IEp_MessageElement element_message = null;
element_upload = wdContext.nodeZfm_Upload_Input().createAndAddZfm_Upload_InputElement();
// element_message = wdContext.nodeEp_Message().createAndAddEp_MessageElement();
InputStream text = null;
int temp=0;
try
{
// wdComponentAPI.getMessageManager().reportSuccess("1");
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
FileOutputStream op = new FileOutputStream(file);
if(wdContext.currentContextElement().getResource()!=null)
{
wdComponentAPI.getMessageManager().reportSuccess("2");
text=wdContext.currentContextElement().getResource().read(false);
while((temp=((InputStream) text).read())!=-1)
{
op.write(temp);
}
}
wdComponentAPI.getMessageManager().reportSuccess("4");
op.flush();
op.close();
path = file.getAbsolutePath();
// wdComponentAPI.getMessageManager().reportSuccess("5");
}
catch(Exception e)
{
e.printStackTrace();
}
// File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
// path = file.getAbsolutePath();
element_upload.setIp_Filepath(path);
wdContext.nodeZfm_Upload_Input().bind(element_upload);
wdComponentAPI.getMessageManager().reportSuccess(path);
wdThis.wdGetUploadCompController().executefm_Upload();
wdComponentAPI.getMessageManager().reportSuccess("5");
when executing this am getting the path as usr/sap/...........
and not getting as C:/Desktop/and file name. That is the reason am not able to get the data .
Saphire added some more on this in another thread which I am merging now here:
I have a Requirement where in i have to generate the excel sheet based on some projects. I have different sets of projects and i want to display different projects in different excel sheets like sheet 1 proj 1 sheet2 proj 2 ..and so on..Currently i have used HTML tags and its working fine the sheets are opening but its all opening in one sheet. Can you please suggest me the code to write in HTML tags so that either i can seperate it based on the projects.
Option2 : If i can change the color of the excel sheets after proj1 so that there is a differentiation on it.;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ervin,
Looking for your expert advice and the code if you have on the same. Am still not able to resolve this issue. I tried using HTML tags and was not success . After that i tried using Jxl.jar but got stuck up and now looking for your help. Could you please provide me the steps to seperate the excel based on the differentiator. Projects ID are dynamic and I dont know how many might be there. So based on the different projects different sheets i want to have.
Workbook excelWB = Workbook.getWorkbook(wdContext.currentContextElement().getExcelResource().read(true)); | |||
Sheet excelSheet1 = excelWB.getSheet(0);// Get the first sheet 1 of the excel Sheet excelSheet2 = excelWB.getSheet(1);// Get the first sheet 2 of the excel Sheet excelSheet3 = excelWB.getSheet(2);// Get the first sheet 3 of the excel |
Now, for each sheet:
for (int j = 0; j < excelSheet.getColumns(); j++) {
int excelRows = excelSheet.getRows();
for (int i = 1; i < excelRows; i++) {
Cell cell = excelSheet.getCell(j, i);// We will read the part numbers only from the first column, second row - This is my custom logic where I need to read only first column and start from second row
CellType type = cell.getType();
if (type != CellType.EMPTY) { // You can check if cell type is label/number/... The code can be writen to behave differently for label, numbers etc.
// Here get the cell value and load it into a context
partNoEle.setMatnr(cell.getContents()); // partNoEle a sample element referring to the context node.
wdContext.nodeExcelPartNos().addElement(partNoEle);
}
}
}
Print out messages, to check if you are reading texts and then, do the addition. But, remeber the template has to be fixed. Any deviation has to agreed as a mistake on the part of the user. Else, if you start considering all test cases then you will spend all effort on this.
Share a template also as part of it, if you want people to follow it.
Regards,
Sharath
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
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.