show zero after import lazarus / 16-Databases ---------------------------------------------------------------------- flori · 2021-03-23 15:13 Hi everyone! I have a small demo which can import xlsm to dbgrid. I use ZeosAcces. After import the cells that were left empty, not filled in writes zero in the dbgrid and dbedit. How can I solve that after import not show zero, just be empty. Thx ---------------------------------------------------------------------- flori · 2021-03-23 16:01 I attached demo ---------------------------------------------------------------------- balazsszekely · 2021-03-23 16:01 @flori Try this: 1. Double click the query, select the "EMAIL" field  2. Go to object inspector, create an OnGetText event 3. Add the following code in the OnGetText procedure's body: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  DispLayText := True;  if ((not Sender.IsNull) and (Trim(Sender.AsString) = '')) or (Sender.IsNull) then    AText := ''  else    AText := Sender.AsString;end; ---------------------------------------------------------------------- flori · 2021-03-23 16:06 @GetMem I attached demo. I tried your code on NUMBER COLUMN. but it shows zeros in the same way ---------------------------------------------------------------------- flori · 2021-03-23 16:12 @GetMem ---------------------------------------------------------------------- flori · 2021-03-23 16:31 it probably doesn't work because the FIELD TYE is float ---------------------------------------------------------------------- balazsszekely · 2021-03-23 16:32 @flori OK. In you initial screenshot you asked something else Please test attached project. I also modified the import code, so delete your records and import from excel again. ---------------------------------------------------------------------- flori · 2021-03-23 16:36 @GetMem I don't see what you sent? ---------------------------------------------------------------------- wp · 2021-03-23 16:42 The import code does not take care of the situation when a cell is empty (cell^.ContentType = cctEmpty) or does not exist (cell = nil). It should write a NULL in this case (Field.Clear). I cannot work out a demo because, as I already told you, I will not pollute my system by installing a huge database system and ZEOS components. ---------------------------------------------------------------------- balazsszekely · 2021-03-23 16:43 @flori Sorry, I forgot to attach the project. ---------------------------------------------------------------------- flori · 2021-03-23 16:50 @GetMem thank you Work fine. I attached another demo. Maybe it will be useful for you too. maybe from here Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Str2Float(AStr: String): Double; ---------------------------------------------------------------------- balazsszekely · 2021-03-23 17:09 @flori Quote I attached another demo. Maybe it will be useful for you too.Thanks for sharing. It's an advanced version of StrToFloat? ---------------------------------------------------------------------- flori · 2021-03-23 17:51 GetMem Instead, I use this code that I sent you. But I long period I use this. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function StringToNumber(innumber: String):real;beginif ((innumber.Length)<1 ) then   StringToNumber:=0else    StringToNumber:= StrToFloat(innumber); end; Did you try "format" your code? In Zquery  Display format is doesn't work when I use this code.    Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  if Sender.FieldName = 'Number' then  begin    DispLayText := True;    if (Sender.IsNull) then      AText := ''    else      AText := Sender.AsString;  end; ---------------------------------------------------------------------- balazsszekely · 2021-03-23 17:59 @Flori Quote AText := Sender.AsString;Yes, I did not use any formatting, because in your first post the field was a string(EMAIL). Later I forget to modify that line. Usually for formatting float, double I use: - Format(..) - FloatToStr(..); - FloatToStrF(..); ---------------------------------------------------------------------- flori · 2021-03-23 18:06 GetMem thanks I use this> and work fine FloatToStr(Sender.AsInteger); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if Sender.FieldName = 'NUMBER' then  begin    DispLayText := True;    if (Sender.IsNull) then      AText := ''    else      AText := FloatToStr(Sender.AsInteger);   end;