Having trouble changing web version to desktop version

The attached file is a simplified version of my web export to excel template. Can you please show me what to change it to allow this to work in my desktop windows form app and windows services? I’m having trouble finding it in your examples. Thanks!

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please use the following modified code in your desktop (WinForm or Console) application.

Also, I recommend you to download and try the Latest Offline Demos of Aspose.Cells for .NET to be familiar with Aspose.Cells API quickly which you can find from theses links.

These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.


Below is a sample code after modification. I have highlighted the changes in red colors.


C#

//Your source file name

string strTemplateFileName = @“F:\Shak-Data-RW\Downloads\source.xlsx”;

Workbook wbook = new Workbook(strTemplateFileName);

Worksheet sheet = wbook.Worksheets[0];


using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[“SQLConnection”].ConnectionString))

{

SqlCommand cmd;

cmd = new SqlCommand(“xxx”, connection);

cmd.CommandType = CommandType.StoredProcedure;


connection.Open();

SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);


//Import the datareader object to the sheet cells

sheet.Cells.ImportDataReader(dr, false, 1, 0, true);

dr.Close();

}


sheet.AutoFitColumns();


//Set the sheet as an active sheet.

wbook.Worksheets.ActiveSheetIndex = 0;


wbook.Save(strTemplateFileName + “.out.xlsx”, SaveFormat.Xlsx);

I've tried that initially. I get the following errors when I try to build but with no warnings before attempting to compile:

Warning 3 The referenced assembly "Aspose.Cells, Version=7.2.0.5, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. GenerateRecurringEmailReports

And Also:

Error 1 The type or namespace name 'Aspose' could not be found (are you missing a using directive or an assembly reference?) C:\Users\RDouglas\Documents\Visual Studio 2010\Projects\GenerateRecurringEmailReports\GenerateRecurringEmailReports\Service1.cs 11 7 GenerateRecurringEmailReports
Error 1 The type or namespace name 'Aspose' could not be found (are you missing a using directive or an assembly reference?) C:\Users\RDouglas\Documents\Visual Studio 2010\Projects\GenerateRecurringEmailReports\GenerateRecurringEmailReports\Service1.cs 11 7 GenerateRecurringEmailReports

Should I use a different version of the dll?

Hi,


As the error suggests and since you are migrating from your Web application to your desktop (e.g console application) where you might not resolve “System.Web” .NET assembly, this assembly is used in your Web application. I think if your VS.NET project’s Target framework is “.NET Framework 4 Client Profile”, then you should use the Aspose.Cells.dll component file located in “net3.5_ClientProfile” folder @ your installation directory. If your VS.NET project’s Target framework is “.NET Framework 4” or other, then you may simply use the Aspose.Cells.dll component file located in “net2.0” folder.

We recommend you to kindly install our latest version i.e. v7.3.4 from here:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry427232.aspx
after installing the version, you will get different Dlls complied versions (net1.1, net2.0, net3.5_ClientProfile etc.). Please use “Aspose.Cells.Dll” in “net3.5_ClientProfile” at your installation directory if your target framework for your desktop application is .NET client profile.

Alternatively, you may change the Target Framework for your desktop application to other than .NET client profile, now you do not need to change the Aspose.Cells.Dll version.

Let us know if you still find the issue.



Thank you.

Wow. That did it. Thanks.

RandyCDouglas:
Wow. That did it. Thanks.
Hi,

Thanks for your feedback.

We are pleased to know that your issue is now resolved.

Let us know if you face any other issue, we will be glad to assist you further.