cancel
Showing results for 
Search instead for 
Did you mean: 

excel file is not deleting from server

Former Member
0 Kudos

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();

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Thanks for reply,Actually i am using jxl for creting excel file after that using resource to set the file . So "file.close" is not possible . I have tried that but its not working if you have any sample code then please send it.

Rakesh

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Anagha,

I am checking after two three days the file is available on server . I have appended dealer user id with file name for make it unique.

Rakesh

Former Member
0 Kudos

Hi,

Provide all the permissions to respective folder

Or else on a windows system provide Every One full control and test. .

Regards

Ayyapparaj