on 10-21-2008 6:39 AM
Hello expert,
I am creating excel file using jxl and in that file i am inserting table data. now the problem is that file is not deleting from the server.please give some suggestion so that i can delete from server .
Thanks and Regards
Kumar Rakesh.
IWDCachedWebResource cachedExcelResource = null;
try
{
String date = DateConvert(new Date(System.currentTimeMillis()).toString());
String user_ex_form= wdContext.currentContextElement().getUser_excel_cfrom();
String fileName = "CFormStatus"dateuser_ex_form+".xls";
File f = new File(fileName);
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableFont red = new WritableFont(WritableFont.ARIAL, WritableFont.DEFAULT_POINT_SIZE, WritableFont.NO_BOLD, false, UnderlineStyle.SINGLE, Colour.RED);
WritableCellFormat redFormat = new WritableCellFormat(red);
WritableFont blue = new WritableFont(WritableFont.ARIAL, WritableFont.DEFAULT_POINT_SIZE, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLUE);
WritableCellFormat blueFormat = new WritableCellFormat(blue);
WritableSheet sheet = workbook.createSheet("C Form Status", 0);
workbook.setColourRGB(Colour.LIME, 0xff, 0, 0);
workbook.write();
FileInputStream excelCSVFile = new FileInputStream(f);
cachedExcelResource =getCachedWebResource(excelCSVFile,fileName,
WDWebResourceType.getWebResourceType("xls","application/ms-excel"));
wdContext.currentContextElement().setRESOURCE(cachedExcelResource);
workbook.close();
f.delete();
Hi,
I just worked on same functionality where i used a button to create excel file with context data and save in local system.
Use the following code under a button, So on click of button you can directly get the excel file saved in to your desktop without saving on the server
String ordcaeno="000"sysdate".XLS";
String str = "";
for(int j = 0; j< wdContext.nodeZflash_File().size(); j++)
{
str =str"\n" wdContext.node<<ABC_File().getABC_FileElementAt(j).getRecord();
}
try
{
IWDCachedWebResource resource = WDWebResource.getWebResource
(
str.getBytes("UTF-8"), WDWebResourceType.UNKNOWN
);
resource.setResourceName(ordcaeno);
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()),
resource.getResourceName());
window.show();
}
catch(Exception ex)
{
wdComponentAPI.getMessageManager().reportException( new WDNonFatalException(ex), false );
}
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ,
To delete the file from the server
File f =new File ("<Path pf the file in server >");
f.delete();
I think you have done this ,but before file delete you please check
the file is closed ,for example you may be using FileInputStrem to
put data into that file ,after that you have to close that connection.
for Ex fis.Close().
check it once,i think this might be the problem ,and also check the file Location your giving when trying to delete is correct.
Regards
Madhavi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kumar,
Did you check immediately or after some time? Not very sure but I think the created excel files reside on the server for some time and then get deleted later.
I had also done similar coding for exporting data to Excel. The file name is appended with timestamp to make it unique and when the file opens, it is also saved on the server. However when I checked after a few hours, only the files with recent timestamps were available in the expected folder on server, and the earlier ones were deleted.
May be you can check after a while.
Regards,
Anagha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.