Click here to Skip to main content
15,898,979 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I used below below code for download the data form com_address table to excel file, excel file will be downloading but data is not coming.

What I have tried:

var addresses = AddressInfoProvider.GetAddresses() .Columns("AddressName", "AddressLine1", "AddressLine2", "AddressCity", "AddressZip", "AddressPhone") .WhereEquals("AddressID", "14");

            foreach (AddressInfo addressInfo in addresses)
            {
              string AddressName = addressInfo.AddressName;
                string AddressLine1 = addressInfo.AddressLine1;
                string AddressLine2 = addressInfo.AddressLine2;
                string AddressCity = addressInfo.AddressZip;
                string AddressPhone = addressInfo.AddressPhone;
            }              
            var websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
            var FileName = "addresses-upload-template.xlsx";
            var exportFilePath = FileHelper.GetFullFilePhysicalPath(ImportExportHelper.GetSiteUtilsFolder()) + FileName;
            WriteFileToResponse(FileName);
Posted
Updated 12-Aug-19 22:22pm

We can't help you with that: it needs your code running and your data available in order to work out what might be going on.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
At a guess - and that's all it can be - your WhereEquals clause is failing to match any rows, so you might want to start there.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
I need to download the data from com_address table to excel file. In the below code

the, data is getting in the address object and file also downloading but data is not coming.
var addresses = AddressInfoProvider.GetAddresses() .Columns("AddressName", "AddressLine1", "AddressLine2", "AddressCity", "AddressZip", "AddressPhone") ;

foreach (AddressInfo addressInfo in addresses)
{
string AddressName = addressInfo.AddressName;
string AddressLine1 = addressInfo.AddressLine1;
string AddressLine2 = addressInfo.AddressLine2;
string AddressCity = addressInfo.AddressZip;
string AddressPhone = addressInfo.AddressPhone;
}
var websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
var FileName = "addresses-upload-template.xlsx";
var exportFilePath = FileHelper.GetFullFilePhysicalPath(ImportExportHelper.GetSiteUtilsFolder()) + FileName;
WriteFileToResponse(FileName);
 
Share this answer
 
Comments
Richard Deeming 13-Aug-19 11:34am    
If you want to update your question, click the green "Improve question" link and edit your question.

If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution and post a comment.

DO NOT post your update or comment as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900