Browse Source

导入Excel,过滤#0字符

MaiXinRong 7 years atrás
parent
commit
1c3feadf1e
2 changed files with 15 additions and 1 deletions
  1. 1 1
      Units/DetailExcelImport.pas
  2. 14 0
      Units/UtilMethods.pas

+ 1 - 1
Units/DetailExcelImport.pas

@@ -128,7 +128,7 @@ function TDetailExcelImport.GetCellStr(ARow: TExportRow;
   ACol: Integer): string;
 begin
   if (ACol < ARow.Cells.Count) and (ACol >= 0) then
-    Result := ARow.Cells[ACol].SqlText
+    Result := TrimInvalidChar(ARow.Cells[ACol].SqlText)
   else
     Result := '';
 end;

+ 14 - 0
Units/UtilMethods.pas

@@ -63,6 +63,7 @@ type
   function CheckPeg(const AStr: string): Boolean;
   function CheckValidPassword(APassword: string): Boolean;
   function ValidInteger(var AKey: Char): Boolean;
+  function TrimInvalidChar(const AText: string): string;
 
   {MergeStrings}
   function MergeRelaBGL(const ABGLCode1, ABGLCode2: string): string;
@@ -684,6 +685,19 @@ begin
   end;
 end;
 
+function TrimInvalidChar(const AText: string): string;
+var
+  i, iLength: Integer;
+begin
+  Result := '';
+  iLength := Length(AText);
+  for i := 1 to iLength do
+  begin
+    if not (AText[i] in [#0]) then
+      Result := Result + AText[i];
+  end;
+end;
+
 {MergeStrings}
 function MergeRelaBGL(const ABGLCode1, ABGLCode2: string): string;
 var