Free Support Forum - aspose.com

Rookie needs help

Edit: Okay, I was able to open the vbproj for the demo. Thanks…


Hi Guys,

As you can see from the subject I am a rookie in .NET development. I have managed to develop a web application using ASP.NET and VB.NET and design through HTML using Visual Studios .NET 2003. We are working on .NET framework 1.1 and using SQL Server 2000.

Basically, the application I have developed is an online report which provides sales data based on date's. Now the users are asking for download functionality into Microsoft Excel spreadsheet. My manager has provided me with this Aspose.Cells software and told me to implement the export functionality so users can download the online data into Microsoft Excel.

But I have no idea on how to proceed. Can anyone please help with the basic building blocks, etc? I tried looking at the demo but its just a bunch of spreadsheets with data inside them..it doesn't actually teach anything. I'm in a desperate situation and any advise/help would be really appreciated. Thanks in advance.

Regards,

S

Hi,

Well, yes, Aspose.Cells has the capability to export data from a variety of data sources to MS Excel spreadsheets. You can use a number of methods / options for your task. E.g., Aspose.Cells.Cells class has a variety of methods i.e., ImportDataTable(), ImportArray, ImportDataGrid, ImportDataRow, ImportDataView etc.

Example Code:

Dim path As String path = Server.MapPath(".")
Dim db As String = path &"\Designer\Northwind.mdb"
Dim con As OleDbConnection = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & db)

con.Open()
Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Order Details]",con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
da.SelectCommand = cmd

Dim ds As DataSet = New DataSet()
da.Fill(ds,"Order Details")
Dim dt As DataTable = ds.Tables("Order Details")
//Create a new workbook
Dim wd As Workbook = New Workbook()
//Get the first wroksheet in the workbook.
Dim sheetResult As Worksheet = wd.Worksheets(0)
sheetResult.Cells.ImportDataTable(dt, False, 2, 0, True)

wd.Save("MyBook.xls", FileFormatType.Default, SaveType.OpenInExcel, Me.Response)

And please check the online documentation for your complet reference: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/index.html

Thank you.

Amjad,

Awesome man, that’s alot of great help. Can you tell me if there is any difference on the method if I’m using data repeaters to fetch my data from the sprocs to the application?

And is typically the data exported out to Microsoft Excel straight from the database or from what the application is showing? Because one the user passes the parameter to the online application, they will first see their results online and then from there they should have the functionality of exporting that specific data for which they provided the parameters onto Microsoft Excel…

Thanks,
S

Hi,

Well, you can either use the source data tables of your repeater controls using Cells.ImportDataTable() method or fill a datareader object and then use Cells.ImportFromDataReader() method to export the data to MS Excel Worksheets.

Furthermore, the data will be exported with pure form without any styles or formattings, so, you have to use your own code using Aspose.Cells APIs to format data to shape your report. Please check the following section and go through its topics and sub-topics for your reference:

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/working-with-data-formatting.html

Feel free to contact us any time if you need further help.

Thank you.

Hey,

I forgot to mention that I already have Excel templates on which I need to export to. The templates have all the formatting in place, etc. Am I able to use that template?

Also, when you refer to "source data tables in repeaters" do you mean the dataset that I generate from my sproc for the repeater?

Thanks,

S

Hi,

Thanks for considering Aspose.

Yes you may utilize your template books using Aspose.Cells and retrieve the data into the their worksheets without any problem.

E.g.,

string path = Server.MapPath(".");
string file = path + "/Designer/summary.xls";
Workbook Workbook1 = new Workbook();
Workbook1.Open(file);
.
.
.

and yes the datatables resides in the dataset.

Thank you.

Slick:

I tried looking at the demo but its just a bunch of spreadsheets with data inside them..it doesn't actually teach anything.

I thank you for sharing this complaint and I will share it with the team. We are construct ingthe next generation demo framework and definitely we will take your complaint into our consideration.

Then I have a question for you as well. How about video tutorials?

http://asp.net/learn/videos/

We are also considering to provide something similar to that. Will that serve you better? I thank you for your valuable input in advance.