New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
writing values in cells who do not contain any values in them #7
Comments
The restriction that you point out is to check indexes boundaries. You could use |
I am getting Here I want to write value in 3rd column. |
Columns and rows indexes are "computer" indexes. In your case, 3rd column index is equal to 2. |
Take a look at this example |
So, As a result, each time you call Moreover, in you next discussion with the community, I suggest you to use code using fenced code block instead of a screenshot. |
I added screenshot for showing the output of code. decoder..insertColumn(workSheet, 2);
decoder..updateCell(workSheet, 2, 0, "c"); should add
Here's the GitHub link of code and |
First of all, I would suggest you again to copy your code, logs and errors as text instead of screenshots. In fact, a screenshot is not relevant to describe your problem.
Moreover, text on screenshot
Then, spreadsheet_decoder is working as expected. I can't help you more. import 'dart:io';
import 'package:spreadsheet_decoder/spreadsheet_decoder.dart';
void dumpTable(SpreadsheetTable table, int rows) {
print("table ${table.maxCols} columns x ${table.maxRows} rows");
for (var row = 0; row < rows; row++) {
var data = "| ";
for (var column = 0; column < table.maxCols; column++) {
data += "${table.rows[row][column]} | ";
}
print("$row = $data");
}
print("");
}
void main(List<String> arguments) {
var bytes = File("poly1.xlsx").readAsBytesSync();
var decoder = SpreadsheetDecoder.decodeBytes(bytes, update: true);
var sheet = 'Sheet1';
var table = decoder.tables[sheet];
print("Loaded table");
dumpTable(table, 3);
// Insert column after last column
var maxCols = table.maxCols;
decoder.insertColumn(sheet, maxCols);
print("After column insertion");
dumpTable(table, 3);
// Update cell at first row in inserted column
decoder.updateCell(sheet, maxCols, 0, 'c');
print("After row update");
dumpTable(table, 3);
File("poly1.xlsx").writeAsBytesSync(decoder.encode());
} First run
Second run
|
Will there be any new method added to write cells ?
Because of restriction placed on
updateCell
only those cells with existing values can be replaced.What to do when have to write cells which do not have any value?
The text was updated successfully, but these errors were encountered: