@@ -159,13 +159,14 @@ internal async IAsyncEnumerable<IDictionary<string, object>> InternalQueryRangeA
159
159
// TODO: need to optimize performance
160
160
// Q. why need 3 times openstream merge one open read? A. no, zipstream can't use position = 0
161
161
162
- var mergeCellsResult = await TryGetMergeCellsAsync ( sheetEntry , cancellationToken ) . ConfigureAwait ( false ) ;
163
- if ( _config . FillMergedCells && ! mergeCellsResult . IsSuccess )
162
+ var mergeCellsContext = new MergeCellsContext { } ;
163
+
164
+ if ( _config . FillMergedCells && ! await TryGetMergeCellsAsync ( sheetEntry , mergeCellsContext , cancellationToken ) . ConfigureAwait ( false ) )
164
165
{
165
166
yield break ;
166
167
}
167
168
168
- _mergeCells = mergeCellsResult . MergeCells ;
169
+ _mergeCells = mergeCellsContext . MergeCells ;
169
170
170
171
var maxRowColumnIndexResult = await TryGetMaxRowColumnIndexAsync ( sheetEntry , cancellationToken ) . ConfigureAwait ( false ) ;
171
172
if ( ! maxRowColumnIndexResult . IsSuccess )
@@ -698,7 +699,7 @@ private async Task<CellAndColumn> ReadCellAndSetColumnIndexAsync(XmlReader reade
698
699
}
699
700
else if ( XmlReaderHelper . IsStartElement ( reader , "is" , _ns ) )
700
701
{
701
- var rawValue = await StringHelper . ReadStringItemAsync ( reader , cancellationToken ) . ConfigureAwait ( false ) ;
702
+ var rawValue = await StringHelper . ReadStringItemAsync ( reader , cancellationToken ) . ConfigureAwait ( false ) ;
702
703
if ( ! string . IsNullOrEmpty ( rawValue ) )
703
704
ConvertCellValue ( rawValue , aT , xfIndex , out value ) ;
704
705
}
@@ -1076,25 +1077,13 @@ internal static async Task<GetMaxRowColumnIndexResult> TryGetMaxRowColumnIndexAs
1076
1077
return new GetMaxRowColumnIndexResult( true , withoutCR , maxRowIndex , maxColumnIndex ) ;
1077
1078
}
1078
1079
1079
- internal class MergeCellsResult
1080
+ internal class MergeCellsContext
1080
1081
{
1081
- public bool IsSuccess { get ; }
1082
- public MergeCells MergeCells { get ; }
1083
-
1084
- public MergeCellsResult ( bool isSuccess )
1085
- {
1086
- IsSuccess = isSuccess ;
1087
- }
1088
-
1089
- public MergeCellsResult ( bool isSuccess , MergeCells mergeCells )
1090
- : this ( isSuccess )
1091
- {
1092
- MergeCells = mergeCells ;
1093
- }
1082
+ public MergeCells MergeCells { get ; set ; }
1094
1083
}
1095
1084
1096
1085
[ Zomp . SyncMethodGenerator . CreateSyncVersion ]
1097
- internal static async Task < MergeCellsResult > TryGetMergeCellsAsync ( ZipArchiveEntry sheetEntry , CancellationToken cancellationToken = default )
1086
+ internal static async Task < bool > TryGetMergeCellsAsync ( ZipArchiveEntry sheetEntry , MergeCellsContext mergeCellsContext , CancellationToken cancellationToken = default )
1098
1087
{
1099
1088
cancellationToken . ThrowIfCancellationRequested ( ) ;
1100
1089
@@ -1110,7 +1099,7 @@ internal static async Task<MergeCellsResult> TryGetMergeCellsAsync(ZipArchiveEnt
1110
1099
using ( XmlReader reader = XmlReader . Create ( sheetStream , xmlSettings ) )
1111
1100
{
1112
1101
if ( ! XmlReaderHelper . IsStartElement ( reader , "worksheet" , _ns ) )
1113
- return new MergeCellsResult ( false ) ;
1102
+ return false ;
1114
1103
while ( await reader . ReadAsync ( ) . ConfigureAwait ( false ) )
1115
1104
{
1116
1105
if ( ! XmlReaderHelper . IsStartElement ( reader , "mergeCells" , _ns ) )
@@ -1119,7 +1108,7 @@ internal static async Task<MergeCellsResult> TryGetMergeCellsAsync(ZipArchiveEnt
1119
1108
}
1120
1109
1121
1110
if ( ! await XmlReaderHelper . ReadFirstContentAsync ( reader , cancellationToken ) . ConfigureAwait ( false ) )
1122
- return new MergeCellsResult ( false ) ;
1111
+ return false ;
1123
1112
1124
1113
while ( ! reader . EOF )
1125
1114
{
@@ -1155,7 +1144,9 @@ internal static async Task<MergeCellsResult> TryGetMergeCellsAsync(ZipArchiveEnt
1155
1144
}
1156
1145
}
1157
1146
}
1158
- return new MergeCellsResult ( true , mergeCells ) ;
1147
+
1148
+ mergeCellsContext . MergeCells = mergeCells ;
1149
+ return true ;
1159
1150
}
1160
1151
}
1161
1152
0 commit comments