More clear method comment on WorkBookDesigner.SetDataSource

SetDataSource(string variable, object data) and SetDataSource(string variable, object[] dataArray) are easily confused.
The former accepts filling from object instance/nested object instance/sequence.
The latter accept filling from an array of primitive types.

@Flithor,

There should be no confusion regarding these overloads.

1). SetDataSource(string variable, object data)
This will do data binding to a simple variable (which is defined in the designer file or template Workbook).
e.g.
Sample code:

var wbd = new WorkbookDesigner();
wbd.Workbook = new Workbook("e:\\test2\\Book1.xlsx");
wbd.SetDataSource("MyVariable", "My Value");

2). SetDataSource(string variable, object[] dataArray)
This will set data binding to a variable array (variable array is defined in the designer file or template workbook).
e.g.
Sample code:

var wbd = new WorkbookDesigner();
wbd.Workbook = new Workbook("e:\\test2\\Book1.xlsx");
wbd.SetDataSource("Array1", new string[5] { "A", "B", "A", "D", "E" });

Hope, this helps a bit.

Uh… I know that. but the comment is not clear enough

SetDataSource(string variable, object data)
“Sets data binding to a variable.”
Actually support an object, or an nested object, or IEnumerable sequence, or single value of primitive type. To fill a form, list, or single cell.

SetDataSource(string variable, object[] dataArray)
“Sets data array binding to a variable.”
Actually support an array of primitive types only, To fill some cells of a column.

When using an object that is an array of class/struct, user should call AsEnumerable() on array to make the compiler use the former overload instead of the latter, as the latter will not support the array of class/struct.

So I said they need more clear comments.

@Flithor
SetDataSource(string variable, object data)
data could be int[],double[],string[],byte[],ICollection, object.
We will look into support IEnumerable later.
It’s the best that calling SetDataSource(string dataSource, ICellsDataTable cellsDataTable) with implemented ICellsDataTable interface to set data source.

Maybe you misunderstand my meaning.
I know that… but the comment of these two methods looks easily make user confused.

I have an array, so which overload should I use?

The comments of them not tell user how to choose a right one:

I have an array of objects (of class type), so maybe I should use object[] overload?
Opps, that’s wrong!

@Flithor
If you have an array of objects (of class type), please use object[] overload.

Are you serious?
Look at this please:
AsposeCellsBugReport.zip (8.7 KB)

@Flithor,
If you call SetDataSource(string variable, object[] dataArray), all elements in the dataArray will be treated as simple data (such as int, double, string…)
As I said in the previous post :The best way is to implement ICellsDataTable yourself, so we can simply treat the data as a table.

I MEANS:
THEY
NEED
MORE
CLEAR
COMMENT

I’m not asking you “What should I do?” or “What’s the best implementation?”.

As I said in the previous post:

The comments of them not tell user how to choose a right one

You answerd me:

If you have an array of objects (of class type), please use object[] overload.

And I tell you:

Your answer is wrong.

BTW: ICellsDataTable is much more worse, I can use “Designer Spreadsheet & Smart Markers”, why ICellsDataTable?

@Flithor
Sorry for my mistake.Now I understand what you mean. The two methods do create confusion. we will delete SetDataSource(string variable, object[] dataArray) method .
I have logged a ticket with an id “CELLSNET-51006” for your issue.
Once we have an update on it, we will let you know.

btw, your code:

wbd.SetDataSource(“Array1”, new string[5] { “A”, “B”, “A”, “D”, “E” });

It’s calling the former one.
string[] cannot implict convert to object[], but can be an object.

@Flithor
Yes, you are right.string[] calls SetDataSource(string variable, object data) method.
We will remove SetDataSource(string variable, object[] dataArray) method in the next release 22.5.

Is it a old and outdated method?
It seems to be in your opinion, the function of object[] overload has been completely replaced by the object overload?

@Flithor
Yes, the function of object[] overload will be completely removed in the next release.

The issues you have found earlier (filed as CELLSNET-51006) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi