Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
justkawal committed May 15, 2020
1 parent d4c46e0 commit 520d803
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/no-response.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an issue is closed for lack of response.
daysUntilClose: 21
daysUntilClose: 30

# Label requiring a response.
responseRequiredLabel: "needs info"
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
All notable changes to this project will be documented in this file.

## [Future Updates coming soon]
- Find and Replace
- Add row / column from Iterables
- Formulas
- Font Family
- Text Size
- Italic
- Underline
- Bold
- Add row / column from Iterables

## [1.0.5] - 2020-05-15
### Removed
- Bugs related to Spanning
- Unwanted removal of rows and columns from spanned cells

## [1.0.4] - 2020-05-10
### Improved
Expand Down
20 changes: 13 additions & 7 deletions example/excel_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:excel/excel.dart';
void main(List<String> args) {
var file = "/Users/kawal/Desktop/excel2.xlsx";
var bytes = File(file).readAsBytesSync();
//var excel = Excel.createExcel();
var excel = Excel.createExcel();
// or
var excel = Excel.decodeBytes(bytes, update: true);
//var excel = Excel.decodeBytes(bytes, update: true);
for (var table in excel.tables.keys) {
print(table);
print(excel.tables[table].maxCols);
Expand Down Expand Up @@ -39,18 +39,24 @@ void main(List<String> args) {
sheet, CellIndex.indexByString("A1"), CellIndex.indexByString("E4"),
customValue: "Now it is merged");

// Insert column at index = 17;
excel.insertColumn(sheet, 17);
excel.merge(
sheet, CellIndex.indexByString("F1"), CellIndex.indexByString("F5"));

excel.merge(
sheet, CellIndex.indexByString("A5"), CellIndex.indexByString("E5"));

// Remove row at index = 17
excel.removeRow(sheet, 2);

// Remove column at index = 2
excel.removeColumn(sheet, 2);

// Insert column at index = 17;
excel.insertColumn(sheet, 2);

// Insert row at index = 2;
excel.insertRow(sheet, 2);

// Remove row at index = 17
excel.removeRow(sheet, 2);

excel.setDefaultSheet(sheet).then((isSet) {
// isSet is bool which tells that whether the setting of default sheet is successful or not.
if (isSet) {
Expand Down
69 changes: 55 additions & 14 deletions lib/src/excel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,35 @@ abstract class Excel {
if (_spanMap[key][j] != null) {
_Span spanObj = _spanMap[key][j];

Map gotMap = _isLocationChangeRequired(
Map<String, List<int>> gotMap = _isLocationChangeRequired(
key, startColumn, startRow, endColumn, endRow, spanObj);
List<int> gotPosition = gotMap["gotPosition"],
changeValue = gotMap["changeValue"][0];
List<int> gotPosition = gotMap["gotPosition"];
int changeValue = gotMap["changeValue"][0];

if (changeValue == 1) {
startColumn = gotPosition[0];
startRow = gotPosition[1];
endColumn = gotPosition[2];
endRow = gotPosition[3];
_spanMap[key][j] = null;
} else {
Map<String, List<int>> gotMap2 = _isLocationChangeRequired(
key,
spanObj.columnSpanStart,
spanObj.rowSpanStart,
spanObj.columnSpanEnd,
spanObj.rowSpanEnd,
checkerPos);
List<int> gotPosition2 = gotMap2["gotPosition"];
int changeValue2 = gotMap2["changeValue"][0];

if (changeValue2 == 1) {
startColumn = gotPosition2[0];
startRow = gotPosition2[1];
endColumn = gotPosition2[2];
endRow = gotPosition2[3];
_spanMap[key][j] = null;
}
}
}
}
Expand All @@ -715,6 +733,7 @@ abstract class Excel {
}
}
}
_cleanUpSpanMap(key);
});

_mergeChangeLook.forEach((key) {
Expand Down Expand Up @@ -950,7 +969,12 @@ abstract class Excel {
startColumn -= 1;
}
endColumn -= 1;
if (startColumn >= endColumn) {
if (/* startColumn >= endColumn */
(columnIndex == (endColumn + 1)) &&
(columnIndex ==
(columnIndex < startColumn
? startColumn + 1
: startColumn))) {
if (!deleteSingleColColor.contains(clr))
deleteSingleColColor.add(clr);
_spanMap[sheet][i] = null;
Expand Down Expand Up @@ -1102,7 +1126,10 @@ abstract class Excel {
startRow -= 1;
}
endRow -= 1;
if (startRow >= endRow) {
if (/* startRow >= endRow */
(rowIndex == (endRow + 1)) &&
(rowIndex ==
(rowIndex < startRow ? startRow + 1 : startRow))) {
if (!deleteSingleRowColor.contains(clr))
deleteSingleRowColor.add(clr);
_spanMap[sheet][i] = null;
Expand Down Expand Up @@ -1321,21 +1348,21 @@ abstract class Excel {
changeValue = 1;
}

if (startColumn >= spanObj.columnSpanStart) {
/* if (startColumn >= spanObj.columnSpanStart) {
startColumn = spanObj.columnSpanStart;
changeValue = 1;
}
if (endColumn <= spanObj.columnSpanEnd) {
endColumn = spanObj.columnSpanEnd;
changeValue = 1;
}
} */
}

if ((startRow < spanObj.rowSpanStart && endRow >= spanObj.rowSpanStart) ||
(startRow <= spanObj.rowSpanEnd && endRow > spanObj.rowSpanEnd)) {
/**
* Start Column stretching to left positionc
* Start Column stretching to left position
*/
if (startColumn >= spanObj.columnSpanStart &&
startColumn <= spanObj.columnSpanEnd) {
Expand All @@ -1351,21 +1378,35 @@ abstract class Excel {
changeValue = 1;
}

if (startRow >= spanObj.rowSpanStart) {
/* if (startRow >= spanObj.rowSpanStart) {
startRow = spanObj.rowSpanStart;
changeValue = 1;
}
if (endRow <= spanObj.rowSpanEnd) {
endRow = spanObj.rowSpanEnd;
changeValue = 1;
}
} */
}
}
if (changeValue == 1) {
if (startColumn > spanObj.columnSpanStart) {
startColumn = spanObj.columnSpanStart;
}
if (endColumn < spanObj.columnSpanEnd) {
endColumn = spanObj.columnSpanEnd;
}
if (startRow > spanObj.rowSpanStart) {
startRow = spanObj.rowSpanStart;
}
if (endRow < spanObj.rowSpanEnd) {
endRow = spanObj.rowSpanEnd;
}
}

return Map<String, List<int>>.from({
"gotPosition": List<int>.from([changeValue]),
"changeValue": List<int>.from([startColumn, startRow, endColumn, endRow])
"changeValue": List<int>.from([changeValue]),
"gotPosition": List<int>.from([startColumn, startRow, endColumn, endRow])
});
}

Expand Down Expand Up @@ -1397,8 +1438,8 @@ abstract class Excel {

Map<String, List<int>> gotMap = _isLocationChangeRequired(
sheet, startColumn, startRow, endColumn, endRow, spanObj);
List<int> gotPosition = gotMap['gotPosition'],
changeValue = gotMap['changeValue'];
List<int> gotPosition = gotMap['gotPosition'];
int changeValue = gotMap['changeValue'][0];

if (changeValue == 1) {
startColumn = gotPosition[0];
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: excel
description: A flutter and dart library for creating, editing and updating excel sheets with compatible both on client and server side.
version: 1.0.4
version: 1.0.5
homepage: https://github.com/kawal7415/excel

environment:
Expand Down

0 comments on commit 520d803

Please sign in to comment.