We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding value to an Exciting Excel Sheet

Hello everyone,

I have an excel which containes number of notes with a certain format that I don't want it to be changed

I only need to pass values to that certin excel ..

but I faild ..

I searched everywhere ... but it's not working with me ...

would you please help me ??!!

this is the code I am using .. but it is creating a new excel sheet .. I don't want this .. I want to have the same data in the excel plus some values...

am using .NET 2008

this is my code ... what should I change to not creat (new) file

but updating the current one and save it in diffrent location..

Dim oExcel As Excel.Application = New Excel.Application

oExcel.Workbooks.Open("D:\Test.xls")

Dim oBook As Object

Dim oSheet As Object

oBook = oExcel.Workbooks.Add

'Add data to cells of the first worksheet in the new workbook.

oSheet = oBook.Worksheets(1)

oSheet.Range("A1").Value = "Last Name"

oSheet.Range("B1").Value = "First Name"

oSheet.Range("A1:B1").Font.Bold = True

oSheet.Range("A2").Value = "Doe"

oSheet.Range("B2").Value = "John"

'Save the Workbook and quit Excel.

oBook.SaveAs("D:\Test1.xls")

oSheet = Nothing

oBook = Nothing

oExcel.Quit()

oExcel = Nothing

GC.Collect()

Hi,

Yes, sure you can perform you task with Aspose.Cells product. I have written a code segment using Aspose.Cells API for your task, see the sample code below:

’…

Imports Aspose.Cells

'…….

Dim workbook As New Workbook()
'Specify the template excel file path.
Dim myPath As String = “D:\Test.xls”
'Open the excel file.
workbook.Open(myPath)

'Get the first sheet.
'Add data to cells of the first worksheet in the new workbook.
Dim oSheet As Aspose.Cells.Worksheet = workbook.Worksheets(0)

oSheet.Cells(“A1”).PutValue(“Last Name”)

oSheet.Cells(“B1”).PutValue(“First Name”)

'Obtaining the style of the cell
Dim style As Style = oSheet.Cells(“A1”).GetStyle()
//Setting the font weight to bold
style.Font.IsBold = true;

'Applying the style to the cell A1 and B1
oSheet.Cells(“A1”).SetStyle(style)

oSheet.Cells(“B1”).SetStyle(style)



oSheet.Cells(“A2”).PutValue(“Doe”)


oSheet.Cells(“B2”).PutValue(“John”)

'Save As the excel file.
workbook.Save(“d:\Test1.xls”)

For complete reference on how to perform different MS Excel features, we recommend you kindly check Aspose.Cells for .NET documentation.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/aspose-cells.html


Thank you.