empty cells in appending data one by one into the google sheet via api v4 - flutter

When i append the list of data in a column the data appended leaves the rows equivalent to the maximum rows used in the previous column and then starts appending from the last cell. The picture would explain the problem quite well. I am using flutter and gsheets dependency to connect to the sheet. Date is the column key and data is the data being appended.
if (column != null) {
if (!column.contains(data)) {
await sheet.values.map.appendRow({date: data});
}
return true;
} else {
await sheet.values.insertColumnByKey(date, [data]);
return true;
}
Current output
Required output

You should find the last cell that contains a value in the target column and insert values starting in the cell just below that cell, instead of appending after the last row of the occupied data range in the sheet.
One way to do that is to use my appendRows_() utility function.

Related

How Do I Generate RowId For Intermediate Group Rows?

I am working on implementing grouping w/ the Server Side Row Model. I need to generate an appropriate ID for the intermediate group rows. For example, if I group by Status then I would have intermediate rows representing each Status (NEW, IN PROGRESS, COMPLETE, etc). I need to come up with a unique ID for these rows (but preferable something deterministic if they need to be accessed/updated later).
The getRowId function is passed an object that contains things like the row's data, the previous parent group values, a reference to the api, etc.
What I would ideally like to know is the current list of group fields... I have all of the values readily accessible, but I don't know what field the current row is being grouped by - else I could just go grab that field from the row's data to use as part of the row id...
Is there any good way to acquire this information?
The columnApi exposes the 'getRowGroupColumns' function from which the field property can be deduced:
getRowId: ({ columnApi, data, level, parentKeys = [] }) => {
const groupColumns = columnApi.getRowGroupColumns();
if (groupColumns.length > level) {
const field = groupColumns[level].getColDef().field;
return [...parentKeys, data[field]].join('-');
}
return [...parentKeys, data.athlete, data.year];
},

Update multiple columns from input in postgres table using pg and express.js in a single query

I have a postgres db that contains the table events. I want a user to be able to update any column or columns of this table via input. The problem with the following code is that when a user updates, for example, the column wedding_name and the otherones do not recieve any value, my row is uptdated succesfully on the columns that received the new value. Howwever, the rest of the columns get empty because they are not recieving inputs. So I want to be able to update one columns, if possible on a sinle query withouth affecting the columns that are not touched.
Thank you.
modifyEvent:async(req, res)=>{
try {
const eventId= req.params.eventId
const {weddingName,groom,bride,location,date,}=req.body
const updatedEvent=pool.query('UPDATE events SET wedding_name=$1,bride_name=$2,groom_name=$3,wedding_location=$4,wedding_date=$5 WHERE wedding_id=$6',[
weddingName,bride,groom,location,date,eventId
])
res.json(updatedEvent)
}
catch (error) {
console.log(error.message)
}
}
You can try something like this :
const updatedEvent=pool.query('UPDATE events SET wedding_name=COALESCE($1, wedding_name), bride_name=COALESCE($2, bride_name), groom_name=COALESCE($3, groom_name), wedding_location=COALESCE($4, wedding_location), wedding_date=COALESCE($5, wedding_date) WHERE wedding_id=$6',[weddingName,bride,groom,location,date,eventId])

Google Sheets REST API 4 get row with specific column

I want to get only one row that contain specific value in one column.
How to make query and set something like: IF "column1" = '3' return that row?
If i use sheets.spreadsheets.values.batchGetByDataFilter
i don't know what to write in DataFilter (now i write only "A:D" to return all rows and columns)
POST https://sheets.googleapis.com/v4/spreadsheets/<Sheet_ID>/values:batchGetByDataFilter?key={YOUR_API_KEY}
{
"dataFilters": [
{
"a1Range": "A:D"
}
]
}

How to insert a table inside a contentControl using Word javascript api

I am developing a word add-in using word JavaScript api, I need to insert some data in table format inside the content Control and placed that content control on top of document.
Please advice.
Thanks.
This should be quite a simple operation. I am assuming that by "On top" of the document you mean inserting a table where the document starts. First line.
All the insertion methods have an insertionLocation parameter that you can use for that purpose. On this case you want to do a body.isnertTable, the 3rd parameter is the insertionLocation ("start" is sent to insert at the beginning of the body of the document).
Once its inserted you can actually wrap it with a content control. Check sample below for details. I included other details, such as applying a built-in style to the inserted table.
hope this unblocks you. thx!
function insertTableAndWrapWithCC() {
Word.run(function (context) {
// We need a 2D array to hold the initial table values
var data = [["Apple", "Orange", "Pineapple"],["Tokyo","Beijing", "Seattle"]];
var table = context.document.body.insertTable(3, 3, "start", data);
table.styleBuiltIn = Word.Style.gridTable5Dark_Accent2;
//now we insert the content control on the table.
var myContentControl = table.insertContentControl();
myContentControl.title = "CC Title";
return context.sync()
})
.catch(function (e) {
console.log(e.message);
})
}

How insert item on top table

How insert item on top table in PostgreSQL? That it is possible? In the table I have only two fields as text. First is primary key.
CREATE TABLE news_table (
title text not null primary key,
url text not null
);
I need a simple query for the program in java.
OK, this is my code:
get("/getnews", (request, response) -> {
List<News> getNews = newsService.getNews();
List<News> getAllNews = newsService.getAllNews();
try (Connection connection = DB.sql2o.open()) {
String sql = "INSERT INTO news_table(title, url) VALUES (:title, :url)";
for (News news : getNews) {
if (!getAllNews.contains(news)) {
connection.createQuery(sql, true)
.addParameter("title", news.getTitle())
.addParameter("url", news.getUrl())
.executeUpdate()
.getKey();
}
}
}
return newsService.getNews();
}, json());
The problem is that as it calls getnews method for the second time this new news adds at the end of the table, and there is no extant hronologi news. How this resolve? I use Sql2o + sparkjava.
Probably already I know. I need to reverse the List getnews before I will must contains object getnews and getallnews?
There is no start or end in a table. If you want to sort your data, just use an ORDER BY in your SELECT statements. Without ORDER BY, there is no order.
Relational theory, the mathematical foundation of relational databases, lays down certain conditions that relations (represented in real databases as tables) must obey. One of them is that they have no ordering (i.e., the rows will neither be stored nor retrieved in any particular order, since they are treated as a mathematical set). It's therefore completely under the control of the RDBMS where a new row is entered into a table.
Hence there is no way to ensure a particular ordering of the data without using an ORDER BY clause when you retrieve the data.