英文:
Laravel to Google Sheets new lines not starting at beginning
问题
I'm using this package to store data from a Laravel app into Google Sheets: https://github.com/kawax/laravel-google-sheets/
Everything works fine except for one strange issue. Here's how I add new lines to the sheet:
$sheet = Sheets::spreadsheet("sheet_name")->sheet("tab_name");
$sheet->append($this->data);
$this->data
contains an associative array with the column names and values.
Most of the times the new lines are added as desired. But sometimes they start in column B with everything shifted over. And now today they are randomly starting in column V.
I can see that the last line in that sheet has values up to column U, so there must be a connection, even though this new line is added five lines lower.
I've not been able to specify a range for the append
method. Is there a way to force Google Sheets to store the data starting from A?
英文:
I'm using this package to store data from a Laravel app into Google Sheets: https://github.com/kawax/laravel-google-sheets/
Everything works fine except for one strange issue. Here's how I add new lines to the sheet:
$sheet = Sheets::spreadsheet("sheet_name")->sheet("tab_name");
$sheet->append($this->data);
$this->data
contains an associative array with the column names and values.
Most of the times the new lines are added as desired. But sometimes they start in column B with everything shifted over. And now today they are randomly starting in column V.
I can see that the last line in that sheet has values up to column U, so there must be a connection, even though this new line is added five lines lower.
I've not been able to specify a range for the append
method. Is there a way to force Google Sheets to store the data starting from A?
答案1
得分: 1
如果有人偶然发现这个,我终于找到了答案。问题似乎是光标或范围在请求之间没有重置,因此输入位置可以根据上次请求的结束位置而变化。解决方案是以这种方式重置范围:
$sheet->range('')->append($this->data);
英文:
If anybody stumbles across this, I finally found the answer. The issue seems to be that the cursor or range isn't reset between requests, so the input position can change depending on where the last request left off. The solution was to reset the range in such a way:
$sheet->range('')->append($this->data);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论