spreadsheet-xlsx icon indicating copy to clipboard operation
spreadsheet-xlsx copied to clipboard

Getting value of empty cell dies

Open zaucker opened this issue 4 years ago • 4 comments

Calling .value on a empty cell dies with

Method 'sync-value-xml' must be implemented by Spreadsheet::XLSX::Cell because it is required by roles: Spreadsheet::XLSX::Cell.

Repro:

use Spreadsheet::XLSX;
my $work-book  = Spreadsheet::XLSX.new;
my $work-sheet = $workbook.create-worksheet('Test');
my $value = $work-sheet.cells[0;0].value;

zaucker avatar Dec 17 '20 08:12 zaucker

I have tried to set a empty value to cells, it also can't work. It says must set a ( int row, int col , string or number ) to cell.So I write a subroutine to judge a variable is defined or not , then set a defined value to cell.

xerox51 avatar Aug 02 '21 11:08 xerox51

@vrurg Does your latest improvements perhaps fix this?

jnthn avatar Feb 12 '23 13:02 jnthn

@jnthn Actually, no. The EmptyCell is returned for when there is a cell but it has no value. Whereas this particular case is about 'no cell exists' situation. For which returning an undefined value is what I would expect it to be.

To make an example from spreadsheet world, clicking a cell doesn't autovivify it. But storing and deleting something does.

BTW, it is now possible to do $work-sheet.cells[0;0]:exists.

vrurg avatar Feb 12 '23 22:02 vrurg

It just crossed my mind that returning Nil would make more sense than returning Cell type object.

vrurg avatar Feb 12 '23 22:02 vrurg