Click here to Skip to main content
14,265,815 members
Rate this:
Please Sign up or sign in to vote.
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 4 days ago
Rate this:
Please Sign up or sign in to vote.

Solution 1

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!
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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);
   
Comments
Richard Deeming 4 days ago
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100