From: Takashi Sawanaka Date: Mon, 21 Mar 2016 15:42:49 +0000 (+0900) Subject: CompareMSExcelFiles.sct: Optimize comparing formulas X-Git-Tag: 2.16.4+-jp-10~746 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=cccb9a02c699b884ec4a4aa11cf323a2153959b7;p=winmerge-jp%2Fwinmerge-jp.git CompareMSExcelFiles.sct: Optimize comparing formulas --- diff --git a/Plugins/dlls/CompareMSExcelFiles.sct b/Plugins/dlls/CompareMSExcelFiles.sct index 8ac1e2771..e0dea9c28 100644 --- a/Plugins/dlls/CompareMSExcelFiles.sct +++ b/Plugins/dlls/CompareMSExcelFiles.sct @@ -96,18 +96,33 @@ Function writeCellValues(fo, sht) End If End Function +Function GetAddr(row, col) + Dim c + c = col - 1 + Do + GetAddr = Chr(65 + (c Mod 26)) & GetAddr + c = (c \ 26) - 1 + Loop While c >= 0 + GetAddr = GetAddr & row +End Function + Function writeFormulas(fo, sht) - Dim rng, row, col, formula - - For row = sht.UsedRange.Row To sht.UsedRange.Row + sht.UsedRange.Rows.Count - 1 - For col = sht.UsedRange.Column To sht.UsedRange.Column + sht.UsedRange.Columns.Count - 1 - Set rng = sht.Cells(Row, Col) - formula = rng.Formula - If Left(formula, 1) = "=" Then - fo.WriteLine rng.Address(False, False) & ": " & formula - End If + Dim row, col, rowOffset, colOffset, varCells, formula + rowOffset = sht.UsedRange.Row + colOffset = sht.UsedRange.Column + varCells = sht.UsedRange.Formula + If TypeName(varCells) = "String" Then + fo.WriteLine GetAddr(rowOffset - 1, colOffset - 1) & ": " & varCells + Else + For row = 1 To UBound(varCells, 1) + For col = 1 To UBound(varCells, 2) + formula = varCells(row, col) + If Left(formula, 1) = "=" Then + fo.WriteLine GetAddr(row + rowOffset - 1, col + colOffset - 1) & ": " & formula + End If + Next Next - Next + End If End Function Function getUsedRangeIncludingShapes(sht) @@ -515,8 +530,8 @@ End Sub
  • - - + +