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

Free Support Forum - aspose.com

Setting cell values

Hi,

is it possible to set a range of cells to some values, or do I have to use PutValue in a loop?

Thanks!

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, if you want to insert the data into range cells then you have to navigate (using any loop) through the range cells and put the values into the cells one by one (By using Cells.PutValue). But if you want the data to be copied from some existing range of cells than you can use Range.CopyData(Range) method.

Thank You & Best Regards,

Thanks for the answer.

Actually I have a rather large two-dimensional array with values. I'm a bit worried that there could be a performance issue if I have to do cell by cell - I remember if I did it this way using the Excel COM API, it was way too slow and as a solution there I could set a range with values in 1 request.

I guess I have to try it to see whether it's performant enough or not?

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, in that case you can use Cells.ImportArray() method to import you two-dimensional array to the

worksheet. Please see the sample code which will help you get your desired result.

Sample Code:

Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
sheet.Cells("A1").PutValue("Import an Array")
sheet.Cells("A1").Style.Font.IsBold = True
Dim arr(1, 1) As String

arr(0, 0) = "Aspose"
arr(0, 1) = "Cells"
arr(1, 0) = "For"
arr(1, 1) = "NET"
sheet.Cells.ImportArray(arr, 1, 0)
Workbook.Save("ImportingData.xls", FileFormatType.Default, SaveType.OpenInExcel, Me.Response)

Also, please check the following link to see different data import options provided by Aspose.Cells.

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/importing-data-to-worksheets.html

Thank You & Best Regards,


Thanks!!!