Skip to content

Commit 7243d53

Browse files
committed
d
1 parent 0443092 commit 7243d53

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

lib/services/excel_service.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// services/excel_service.dart
12
import 'package:excel/excel.dart';
2-
import 'package:flutter/material.dart'; // Added import for Colors
33

44
class ExcelService {
55
Future<List<int>?> convertJsonToExcel(List<dynamic> data) async {
@@ -10,15 +10,16 @@ class ExcelService {
1010
List<String> headers = ['Username', 'Password', 'Auth Code', 'Email'];
1111
for (int i = 0; i < headers.length; i++) {
1212
var cell = sheetObject.cell(CellIndex.indexByColumnRow(columnIndex: i, rowIndex: 0));
13-
cell.value = headers[i];
13+
cell.value = TextCellValue(headers[i]); // Use TextCellValue for strings
1414

1515
// Create a font with white color
16-
var font = Font(colorHex: "#FFFFFF");
16+
var font = Font()
17+
..colorHex = "#FFFFFF"; // Use property assignment instead of constructor parameter
1718

1819
// Apply cell style with the font
1920
cell.cellStyle = CellStyle(
2021
bold: true,
21-
font: font, // Use the font object instead of fontColor
22+
font: font,
2223
backgroundColorHex: '#4F81BD',
2324
);
2425
}
@@ -28,16 +29,16 @@ class ExcelService {
2829
final item = data[i];
2930

3031
var usernameCell = sheetObject.cell(CellIndex.indexByColumnRow(columnIndex: 0, rowIndex: i + 1));
31-
usernameCell.value = item['username']?.toString() ?? '';
32+
usernameCell.value = TextCellValue(item['username']?.toString() ?? ''); // Use TextCellValue
3233

3334
var passwordCell = sheetObject.cell(CellIndex.indexByColumnRow(columnIndex: 1, rowIndex: i + 1));
34-
passwordCell.value = item['password']?.toString() ?? '';
35+
passwordCell.value = TextCellValue(item['password']?.toString() ?? ''); // Use TextCellValue
3536

3637
var authCodeCell = sheetObject.cell(CellIndex.indexByColumnRow(columnIndex: 2, rowIndex: i + 1));
37-
authCodeCell.value = item['auth_code']?.toString() ?? '';
38+
authCodeCell.value = TextCellValue(item['auth_code']?.toString() ?? ''); // Use TextCellValue
3839

3940
var emailCell = sheetObject.cell(CellIndex.indexByColumnRow(columnIndex: 3, rowIndex: i + 1));
40-
emailCell.value = item['email']?.toString() ?? '';
41+
emailCell.value = TextCellValue(item['email']?.toString() ?? ''); // Use TextCellValue
4142
}
4243

4344
// Auto-size columns

0 commit comments

Comments
 (0)