tanaikech / RangeListApp

RangeListApp is a GAS library for retrieving, putting and replacing values for Spreadsheet by a range list with a1Notation using Google Apps Script (GAS).
MIT License
26 stars 5 forks source link

Doesn't work #1

Open Kirajav opened 4 years ago

Kirajav commented 4 years ago

Your simple example, a little bit modified:

var rangeList = ["A1", "B2", "C3:D4"];
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var r = RangeListApp.getSpreadsheet(spreadsheet).getRangeList(rangeList).getValues();
Logger.log(r);

returns me:

[{values=[[Nombre]], range=Data!A1}, {values=[[123141445]], range=Data!B2}, {range=Data!C3:D4}]

in log console, but not the actual data values in cells for each range as expected.

tanaikech commented 4 years ago

Thank you for your comment. In my environment, I could confirm that your script works. In your ranges, the values are retrieved from the cells of "A1", "B2", "C3:D4" on the 1st tab in the active Spreadsheet. Ref

Kirajav commented 4 years ago

Thank you by your quick response! yeah, but i expected an array with just the values as the original .getValues(); method response in GAS

tanaikech commented 4 years ago

Thank you for replying. Unfortunately, this library uses Sheets API. So in the current stage, your goal cannot be directly achieved. This is due to my poor skill. I deeply apologize for this.

Kirajav commented 4 years ago

No, don't worry, actually you are more skilled than me! but thank you anyway! I'll try to investigate more and if i find the problem, I'll let you know it. And again, thanks for sharing!

tanaikech commented 4 years ago

I would like to consider for implementing this in the future update. Thank you for proposing this.

tehhowch commented 4 years ago

Thank you by your quick response! yeah, but i expected an array with just the values as the original .getValues(); method response in GAS

@Kirajav How should that even work? There is no strict requirement on the size of any individual range, so you can end up with a very jagged array. Nor is there a requirement that only row-oriented ranges are provided.

E.g., what sort of response do you expect from this library's getValues() when the ranges in the RangeList are A1:A100, A1:ZZ1, B5, C10, F2:G2, and AAB3?

tanaikech commented 4 years ago

@tehhowch Thank you for your support. Your comment helps me think of the Kirajav's comment. I could notice that my understanding of it was not correct. So I would like to wait for Kirajav's replying.

Kirajav commented 4 years ago

@tanaikech i expected to get an array of arrays, i mean, something like this: [[1,2,3],["A","B","C"],["John", "Marie", "Susane", "Lois"],["something"]] if each rage you mentioned has that respective data in the respective cells. But, with this library, the function getValues() returns me the ranges' names like this:

[{values=[[Nombre]], range=Data!A1}, {values=[[123141445]], range=Data!B2}, {range=Data!C3:D4}]

tanaikech commented 4 years ago

Thank you for replying. The returned values are the array object. So in this case, as the current workaround, how about creating the array, that you want, from the returned values using a script?

tehhowch commented 4 years ago

@Kirajav you are one simple step from your desired output: instead of an array of 2D arrays, you have an array of objects, each of which has the 2D array you want as a named property. Just map the return value:

...getValues().map(function (result) {
  return result.values;
});

That this library provides the reference of the source range and not just the values is actually a good thing, as it decreases coupling and improves the ability of consuming applications to work with the library.