Write Collection Direct0-631.257f99ecc6-c8d5-4f76-980e-945380988e38Writes the given collection into the specified sheet.-195-105180907f99ecc6-c8d5-4f76-980e-945380988e3845-135603094411eff-31dc-41ad-8569-444908993fb57f99ecc6-c8d5-4f76-980e-945380988e38456060307f99ecc6-c8d5-4f76-980e-945380988e38-255-3012030number7f99ecc6-c8d5-4f76-980e-945380988e38-2556012030text7f99ecc6-c8d5-4f76-980e-945380988e38-2551512030text7f99ecc6-c8d5-4f76-980e-945380988e38-1356012030flag7f99ecc6-c8d5-4f76-980e-945380988e3845-7512030d36b4ab6-34b1-4eb5-9d3a-dffc1c294215733c2840-8162-465a-a8f2-7d023087c3697f99ecc6-c8d5-4f76-980e-945380988e3845-1512030d06de8c0-76d8-4e01-ae58-aea82f0e598c dtRowCount Then
blRowCount = dtRowCount - blStart
Else
blRowCount = rowlimit
End If
Dim objXlData(blRowCount, dtColCount) As Object
For iRow As Integer = blStart To blStart + blRowCount - 1
For iCol As Integer = 0 To dtColCount - 1
If IsDBNull(Collection.Rows(iRow).Item(iCol)) Then
objXlData(iRow-blStart, iCol) = ""
Elseif TypeOf Collection.Rows(iRow).Item(iCol) is String then
If Left(Collection.Rows(iRow).Item(iCol),1) = "=" then
objXlData(iRow-blStart, iCol) = "'" & Collection.Rows(iRow).Item(iCol)
Else
objXlData(iRow-blStart, iCol) = Collection.Rows(iRow).Item(iCol)
End if
Elseif TypeOf Collection.Rows(iRow).Item(iCol) is DataTable then
Dim sw as StringWriter = new StringWriter()
Collection.Rows(iRow).Item(iCol).WriteXml(sw)
objXlData(iRow-blStart, iCol) = sw.ToString()
Else
objXlData(iRow-blStart, iCol) = Collection.Rows(iRow).Item(iCol)
End If
Next
Next
xlWorkSheet.Range(cellref).Offset(OffsetRow+blStart,0).Resize(blRowCount, dtColCount).Value = objXlData
'below SetProperty does the same as above, but uses system Culture, which is inconsistent. I intentionally dont want to do that.
'SetProperty(xlWorkSheet.Range(cellref).Offset(OffsetRow+blStart,0).Resize(blRowCount, dtColCount), "Value", objXlData)
objXlData = Nothing
GC.Collect()
Next
xlWorkSheet=Nothing
Collection = Nothing
System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce
GC.Collect() ]]>7f99ecc6-c8d5-4f76-980e-945380988e38-135-3012030textA17f99ecc6-c8d5-4f76-980e-945380988e38-1351512030number5000