PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD19] and Gembox - Another attempt
[WD19] and Gembox - Another attempt
Iniciado por guest, 02,jun. 2015 10:01 - 8 respuestas
Publicado el 02,junio 2015 - 10:01
I am making progress with accessing the Gembox features but the problem I have is to access a specific worksheet, a specific row or specific cells.

I have the following with my comments on what is working

ef is "GemBox.Spreadsheet.ExcelFile"
//This loads an existing empty xlsx file
ef <- ExcelFile.Load("C:\My Sites\PlumAccounting\Exe\PlumAccounting_NOB97010\0\Test.xlsx")
//This loads the data into Sheet 1 of the above file
ef.LoadCsv("C:\My Sites\PlumAccounting\Exe\PlumAccounting_NOB97010\0\ActualvsBudget.csv",",")
//This supposedly adds another sheet to the existing spreadsheet
//If I return ef.worksheets.count it returns 2 so I think it is working
ef.Worksheets.Add("Sheet2")
//Now I want to ensure that I am working with the newly added worksheet so according to the Gembox documentation the recently added sheet becomes the ActiveWorksheet
//The code below is not giving an error and is supposed to 'load' the active worksheet.
ew is ExcelWorksheet <- ef.Worksheets.ActiveWorksheet
//However now I want to work with one row on this worksheet
//The line below is accepted
er is ExcelRow <-ew.Rows
//but if I want to change the details of 1 row there is no way I can do that
//this gives an error that er is a COLLECTION of rows (ExcelRowCollection). I want to work with 1 row
er.Style.Font.Weight = ExcelFont.BoldWeight
//I have tried various ways to refer to a single row i.e.
er[1].Style.Font.Weight = ExcelFont.BoldWeight
er(1).Style.Font.Weight = ExcelFont.BoldWeight
//I have tried this to indicate that I am only working with Row 1. Although the code does not give an error at execution you get message that you cannot access a sub-element
er is ExcelRow <-ew.Rows[1]

Is there anybody that can help please?

Thanks in advance.


Ericus Steyn
Publicado el 04,junio 2015 - 17:23
Please check the .NET samples for GemBox and then try to do the same in WD.

Yogi Yang
Publicado el 04,junio 2015 - 21:13
Thanks Yogi

I have followed the examples closely and the C# ones are very close to the syntax in Windev.

It is to point to a specific worksheet, row or cell that is a problem.

As soon as I refer to any object i.e. row[9] for example that I get an error 'sub-element is not available'.

I have tried any possible syntax to refer to a single object with no success

Regards


Ericus Steyn
Publicado el 05,junio 2015 - 00:36
Hello Ericus

You might also try talking to Gembox.
From personal experience with their MS Word product, their level of support is very good, typically they respond within hours and if the problem is on their side they will make changes. We had a problem with PDF conversion and when PCSoft tech support couldn't help, Gembox altered their process to make their software work with Windev and you can't ask for better support than that.

Regards
Al
Publicado el 05,junio 2015 - 10:31
Hi Al

You are right about Gembox support. Been dealing with a Mario there and he tried as best he could. For anybody else interested:

//This all works
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
ef is ExcelFile dynamic = new ExcelFile
ef.Worksheets.Add("Sheet1")
ef.Worksheets.add("Sheet2")
clEwc is ExcelWorksheetCollection <- ef.Worksheets
//this is the problem. The syntax to refer to ONE specific sheet.
ew is ExcelWorksheet dynamic <- clEwc[1] //Does not work

//Does not work if you creat an array
clEwc is Array ExcelWorksheetCollection <- ef.Worksheets
ew is ExcelWorksheet dynamic <- clEwc[1]

No syntax of [1] works.

Frustration!!!
Publicado el 05,junio 2015 - 11:13
Hi.
In the windev help says that arrays of objects are not supported.
I also tried yesterday some basic example and could not make it to work.
http://help.windev.com/…

Regards,
Jose Antonio.
Publicado el 05,junio 2015 - 11:27
Thanks Jose

Array is just one way I tried to access a single worksheet or cell.

In windev you either get a syntax error on [] if you use square brackets or alternative you get an error sub-element not available.

Regards
Publicado el 05,junio 2015 - 14:29
Hi Ericus,

Has WD created an interface with functions like get_ExcelWorksheetCollection( n ) or something in the like? I remember having seen stuff like that. Then I was able to call the "get" function to get the required item I was looking for. (This would solve the "array" problem.)

Best regards,
Alexandre Leclerc
Publicado el 05,junio 2015 - 16:14
Yes Alexander the interface everything is there.

For instance:

//other stuff before this
ef is ExcelFile dynamic = new ExcelFile
clEwc is ExcelWorksheetCollection <- ef.Worksheets
//This should add one sheet
ew is ExcelWorksheet dynamic = clEwc.Add("Sheet1")
//This should add another sheet
ew2 is ExcelWorksheet dynamic = clEwc.Add("Sheet2")
//This does not give an error
clEwc.set_ActiveWorksheet(ew2)

but consistently my spreadsheet is created with one sheet called 'Sheet1' containing the important data.

if I do a sheet count in the debug it shows 2 sheets but the spreadsheet, when opened, contains one sheet and the data is always in sheet 1.

Regards


Ericus Steyn

clEwc.set_ActiveWorksheet [1] -