I am migrating from excel in vb.net to asposecells in c# could find activating the sheet and other stuff

hi i am trying to convert an application from vb.net using excel api to aspose.cells using c#

Having some trouble in converting some excel statements to c #

Dim xlsApplication As New Excel.Application

Dim ThisWB As Excel.Workbook

Dim exlPdf = New Aspose.Cells.Workbook()

Dim xlsWorkbooks As Excel.Workbooks

xlsWorkbooks = xlsApplication.Workbooks

ThisWB = xlsWorkbooks.Add

Dim outSheet As Excel.Worksheet

outSheet = ThisWB.Sheets(2)

outSheet.Select()

outSheet.Activate()

' Assign the Connection object.

..outSheet.Application.ActiveCell.Value = "N/A"

outSheet.Application.ActiveCell.Offset(1, 0).Select()

outSheet.Application.ActiveCell.Offset(0, -16).Select()

Thank you very much

Hi,

I think you may check the document for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/activating-sheets-and-making-an-active-cell-in-the-worksheet.html

Thank you.

Hi thanks for the replay i am mainly conerned about

outSheet.Select();

outSheet.Application.ActiveCell.Value = "N/A";

outSheet.Application.ActiveCell.Offset(1, 0).Select();

i could find these

outSheet.Select();

outSheet.Application.ActiveCell.Offset(1, 0).Select();

Unable to find these stuff Thank you very much in advance

Hi,

Can you tell me what this code snippet does? An excel file or screenshots will be very much helpful. After look into it, we will provide you equivalent code if they are available in Aspose.Cells.

I am trying to print data from database to excel

i used it in vb.net using excel api

right now i am converting it to aspose using c# so if can provide me that would be great

Thanks for the reply

Hi,

Aspose.Cells for .NET does provide a variety of options to extract data from data sources / databases. You can use ImportDataTable, ImportDataView, ImportFromDataReader or even ImportArray methods to import data from these sources and extract data to fill the worksheet cells.
See the document for your complete reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/importing-data-to-worksheets.html

Thank you.

Good afternoon

Thats a good information thank you very much , i am wondering about these two function

i want same functions in aspose.cells

outSheet.Select();

outSheet.Application.ActiveCell.Offset(1, 0).Select();

i used these using interop.excel function right now i am trying to do using aspose.cells

but unable to find these two

Hi,

Well, I am not an expert of Excel Automation API. So, I am not completely sure about your two lines of code.

1) For the line:
outSheet.Select();

If you need to access a sheet for your specific purpose. For example, you need to copy or move a sheet to other Workbooks. Or you need to remove a sheet in the workbook or so etc.
Here is a sample code how to get a worksheet in a workbook:
//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(“C:\book1.xls”, FileMode.Open);

//Opening the Excel file through the file stream
workbook.Open(fstream);

//Obtaining the reference of the first worksheet in the book by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

//Or by name
//Worksheet worksheet = workbook.Worksheets[“Sheet1”];



Please go through these topics if they are useful for your.

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/managing-worksheets.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/copying-and-moving-worksheets.html


2) For the line:
outSheet.Application.ActiveCell.Offset(1, 0).Select();

If you need to get a specific cell with respect to a cell in the worksheet. For example you need to format the cell, add value or even copy a range to other range or perform other operations etc.

See the documents for your reference if they are useful for you:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/accessing-cells-of-a-worksheet.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/adding-data-to-cells.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/named-ranges.html


Thank you.

Thanks amjad i hope this works if not i will let you know

Thanks for the help