473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I have a problem to create and download excel file at a time

I has made two method ExcelCreat() which create excel file And ExcelDownload() which download that excel file.both work separate properly but not ata time. I make a builder.append("<"<a href='/RestSimulator/rest/userReport/download' onclick='javascript:ExcelCreate();'>Download</a>");
prblem is that when I click href(Download) then excel is not created show error 500 file not found but we again press that link then file download.it means first time excel does not genetare but second time generate HOW TO CALL ExcelCreat() method first
Jul 3 '14 #1
1 1742
rajujrk
107 100+
Hi,

You trying to call 2 Javascript functions one by one immediately. Both functions are calling the Web/App Server and doing server side functionality. Coming to your problem, first you are trying to call the Create ExcelCreate (Which is processing to create a new excel file), Note: its still in process from server side. Before ending this process, immediately ExcelDownload is start to execute and trying to download the file, but file not created yet. This way will not work out.

My Soultion 1: (use AJAX)

1. In server side Excel Creation method, set a session variable say "FILEPROCESS" and set the value as "false". Once file created set the "FILEPROCESS" to true.

2. Create a new server side service called StatusService, inside this services just write out the session "FILEPROCESS" value.

3. Create one global boolean variable blgFlg = false in your javascript

2. Inside ExcelCreate() - Call new Javascript method called getStatus() before calling the server side services

3. Inside the getStatus() function use Ajax to call the StatusService and set the response Text to blgFlg variable.

4. If blgFlg = false, then call setTimeout('getStatus()', 500);

5. If blgFlg = true, then call ExcelDownload()


My Soultion 2:

Instead of having 2 javascript function, use 1 javascript function and use 2 server side methods

If you have any clarifications, please continue to post ur reply

Thanks
Raju
Jul 3 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Cathy Bro | last post by:
I have been able to create and Active Server Page that when I link to it will ask if I want to download to an excel file which I do want. It works well, but there is one thing that I haven't been...
0
by: Pankaj Garg | last post by:
I have written a program, where I download reports in PDF or Excel format, depends on user selection. My code is working fine for PDF format, but same code os not working for excel file. When I...
7
by: Martin | last post by:
I have a situation where I'm displaying some information in a table on a web page. I've given the user the ability to make several different "queries" and show different sub-sets of the data. I...
27
by: jeniffer | last post by:
I need to create an excel file through a C program and then to populate it.How can it be done?
15
by: patf | last post by:
Hi - experienced programmer but this is my first Python program. This URL will retrieve an excel spreadsheet containing (that day's) msci stock index returns. ...
0
by: dbncourt | last post by:
Using c#, i want to create a Excel file in a given path and name. So far i found this, that could work but it doesnt! oWB.SaveAs(filePath, ".xls", Missing.Value, Missing.Value , Missing.Value ,...
2
by: Brian Connelly | last post by:
Hello, I am currently having issues with the following code when trying to create a excel file using C#. This is the code that I have at the moment. oXL = new...
3
by: MNNovice | last post by:
Hi, I am using Access 2007. I have been using an Access report to create an Excel file by manually entering the same data. I was wondering if it's possible to export data from an Access report...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.