A Programmer Goes to Dentist

This unwanted true story was happened to me last Sunday when I suddenly giving up holding super duper sickness sensation at bottom right side of my gums. In that days, a big swollen at right cheek appears for 48 hours before. The story begun in Saturday morning when I having a relax time by chewing a hot spicy crispy chips of cassava called balado (my favorite junk food). Somehow, a small pieces of it had wounded my bottom right gums but I didn’t realized that it would be my bad luck.



At early evening, the gums looks puffy but still I can enjoy the food at McDonald located in Tamini Square Mall. At night, the puffy even more looks bigger makes my cheek appear different and finally here comes the true pain as I can’t sleep for the rest hours. Ohh dear god…. As much as the swollen more bigger, a teeth above it felt shaky.

I hold back the pain until Monday morning but in a last seconds I give up. I can’t stands for more & finally decided goes to hospital. Next minutes, I was in dental medicinal treatment & experiencing the thing that I had never done before. At the end, the doctor gives me 4 kinds of potions; which was a bottle of common liquid antiseptic, Ponstan, Lincomycin & Nutriflam. I don’t have any idea what was that each of it purposed to, however my cheek & gums slowly shrank insignificantly. Anyway, I’d like to apologize about some missed appointments to my clients because of this unwanted condition & this would be understanding of a situation.

Labels: , , ,

  Post a Comment Bookmark and Share

Exporting Data to Excel from Delphi: The Trick

Anyway, I had concealed this topic somehow for several years after finalized my last project contains an Excel spreadsheet module exported from database. I knew that what I show you below is a kind of old-fashioned and everyone will know how to did it, but I wrote it just for me. Nothing more except for remind my self that I used to have a project which deal with database and Excel.

The subject is Delphi, records in a database and Microsoft Excel application. It have really quite simple process: retrieve the data into a component and move the records to Excel sheet grid by grid. You may said that this one is a stupid way, but believe me… this stupid way will work great.

Let’s assumed that you have the way how to retrieve data sources, since I’ll not talk about how to do that. What I tried to explain is a method how to transfer it to Excel. Strike to the point, simply add the blank form with TDBGrid, TButton and few components got from Servers tab such as TExcelApplication, TExcelWorkBook, TExcelWorkSheet and optionally TExcelQueryTable if you plan to do more action.



Whatever the event is, just make a connection to database and display the records into TDBGrid component. Once you do that, I’ll show you the rest of the step.



TButton component purposed to trigger the opening of Microsoft Excel and transfer one by one records into it. But first, you have to catch the total number of the records and fields then use it as the looping procedure, the grid by grid data mover horizontally and vertically start from header until end of records. See below example code:

baris:=q1.RecordCount; // number of rows
kolom:=DBGrid1.FieldCount; // number of columns

objExcel := TExcelApplication.Create(nil);
objExcel.Visible[0] := TRUE;
objWB := objExcel.Workbooks.Add(null,1);
for j:=1 to kolom do
objWB.Worksheets.Application.Cells.Item[1,j]:=DBGrid1.Fields[j-1].DisplayName;

q1.First; // TQuery component
for i:=1 to baris do
begin
for j:=1 to kolom do
objWB.Worksheets.Application.Cells.Item[i+1,j]:=DBGrid1.Fields[j-1].AsString;
q1.Next;
end;

objExcel.Free;


Okay, let’s execute the application, press the button and see the result. Voila! Now you have an Excel with records imported from database directly.



Pretty simple isn’t it?

Labels: ,

  Post a Comment Bookmark and Share