Giter Site home page Giter Site logo

Comments (8)

justkawal avatar justkawal commented on August 12, 2024 4

Sorry, for issues in this library, I'm doing some structure changes in my local repo and would be releasing soon.
Again sorry for the issues.... I'm trying my best to keep this project alive while searching for the jobs.

Thanks for understanding.
Much appreciated.

from excel.

innovatoraakash avatar innovatoraakash commented on August 12, 2024 2
   _updateCell(sheetName, foundRow, columnIndex, rowIndex, data.value,
            data.cellStyle?.numberFormat); 

main point of error is from here. If we do not specify the cellStyle it gives format null error and thows exception .
I got this error from sheetObject.insertRowIterables() where I can't set any cellstyle
If you got problem from same method you can use this fork

  excel: 
    git:
      url: "https://github.com/innovatoraakash/excel"

Giving a default format on this will be productive and easier for everyone.

from excel.

zxkfall avatar zxkfall commented on August 12, 2024 1

I met the same question when using save method to save excel, This is my code:

var excel = Excel.createExcel();
    Sheet sheetObject = excel['Sheet1'];

    sheetObject.appendRow([
      const TextCellValue('Date'),
      const TextCellValue('Amount'),
      const TextCellValue('Type'),
      const TextCellValue('Kind'),
      const TextCellValue('Description')
    ]);
    var billings = await GetIt.I<BillingRepository>().billings();
    for (var billing in billings) {
      developer.log('message, ${DateTimeCellValue.fromDateTime(billing.date)}');
      sheetObject.appendRow([
        DateTimeCellValue.fromDateTime(billing.date),
        DoubleCellValue(billing.amount.toDouble()),
        TextCellValue(billing.type == BillingType.expense ? 'COST' : 'INCOME'),
        TextCellValue(billing.kind.name),
        TextCellValue(billing.description)
      ]);
    }
    var fileBytes = excel.save();

For appendRow method, it works fine. But when I invoke save() method, it will throw exception like this:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: null does not work for DateTimeCellValue
#0 Save._createCell (package:excel/src/save/save_file.dart:142:16)
#1 Save._updateCell (package:excel/src/save/save_file.dart:997:16)
#2 Save._setRows (package:excel/src/save/save_file.dart:652:9)
#3 Save._setSheetElements. (package:excel/src/save/save_file.dart:966:7)
#4 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#5 Save._setSheetElements (package:excel/src/save/save_file.dart:914:22)
#6 Save._save (package:excel/src/save/save_file.dart:544:5)
#7 Excel.save (package:excel/src/excel.dart:348:21)
It looks like I can not use DateTimeCellValue and DoubleCellValue. If I use TextCellValue, it will not throw exceptions.
@AbhiralJain

from excel.

sakshitporwal avatar sakshitporwal commented on August 12, 2024 1

I am getting the same error on DateCellValue, IntCellValue, DoubleCellValue. No matter how i try to implement it.
Something seems to be going wrong in .save() method.
Any soultion to this? Also setColumnWIdth() & setRowHeight() dosent seem to work anymore

from excel.

AbhiralJain avatar AbhiralJain commented on August 12, 2024

@Epiwish Hi, If you want to update cell using DateTimeCell value, you need to provide the format using numberFormat parameter in cellStyle.

Here is an example:
sheetObject.updateCell(
CellIndex.indexByString('C$i'),
DateTimeCellValue(
year: 1,
month: 1,
day: 1,
hour: 1,
minute: 1,
second: 1,
),
cellStyle: CellStyle(
numberFormat: NumFormat.defaultDate,
),
);

from excel.

Epiwish avatar Epiwish commented on August 12, 2024

@Epiwish Hi, If you want to update cell using DateTimeCell value, you need to provide the format using numberFormat parameter in cellStyle.

Here is an example: sheetObject.updateCell( CellIndex.indexByString('C$i'), DateTimeCellValue( year: 1, month: 1, day: 1, hour: 1, minute: 1, second: 1, ), cellStyle: CellStyle( numberFormat: NumFormat.defaultDate, ), );

How can I set cellStyle when using excel.save()?
I'm just trying to create a new excel file with some DateTimeCellValues

from excel.

DucAnh-Vu-Trinh avatar DucAnh-Vu-Trinh commented on August 12, 2024

I also get the same error when using excel.save(). Is there any workaround in the meantime?

from excel.

ratiger avatar ratiger commented on August 12, 2024
   _updateCell(sheetName, foundRow, columnIndex, rowIndex, data.value,
            data.cellStyle?.numberFormat); 

main point of error is from here. If we do not specify the cellStyle it gives format null error and thows exception . I got this error from sheetObject.insertRowIterables() where I can't set any cellstyle If you got problem from same method you can use this fork

  excel: 
    git:
      url: "https://github.com/innovatoraakash/excel"

Giving a default format on this will be productive and easier for everyone.

your update work only for int vaule , but I got error when used datetime, so i eventually used text for my datetime.

from excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.