Update the Spreadsheet - Mission Impossible?

Posts: 8
Hi Nick!

I saw an old post about update Spreadsheet in ATVO Theme and I started to code some stuff to understand how it works.
So, here is my Spreadsheet inside the project content:



And here is the content:



My code is trying to do a simple update in column[1] and save the spreadsheet:

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data;
using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace Scripts
{
public class test : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var sheet = item.Theme.Spreadsheets.Find("datasetLe.csv").Table.Data.Copy();
DataRow data = null;

foreach(DataRow row in sheet.Rows)
{
if((int)row[0] == 1234)
{
data = row;
data[1] = "QWERTY";
}
}

item.Theme.Spreadsheets.Find("datasetLe.csv").Table.Data.Clear();
item.Theme.Spreadsheets.Find("datasetLe.csv").Table.Data.Load(sheet.CreateDataReader());
item.Theme.Spreadsheets.Find("datasetLe.csv").Table.Data.AcceptChanges();

Console.WriteLine("Teste!!!");
return "";
}

}
}



Testing the code, I got no errors and the Spreadsheet updated(?):



Checking the file inside the project folder:



So, I closed the ATVO Theme Editor and opened it again and checked the content of the Spreadsheet in the editor:



Well.. Is it possible to update the file? What is wrong in my code?

Thanks!
Posts: 785
You're only updating the spreadsheet in memory, never saving it back to the file.