Banyak cara untuk meng-import data dari file excel menggunakan delphi, berikut ini saya berikan contoh import data dari file excel dimana file excel yang akan diimport dikonversi terlebih dahulu menjadi file text (*.txt).

Contoh simulasi :

Misal saya ingin meng-import data karyawan seperti dibawah ini :

Note :

Jika ada data berisi angka maka rubah dahulu menjadi format number dengan cara blok kolom yang berisi angka tersebut kemudian klik kanan dan pilih “Format Cells” sampai muncul tampilan berikut :

kemudian silahkan “Save As” file tersebut menjadi tipe file –> Text (Tab delimiter) (*.txt)

Langkah berikutnya yaitu kita langsung coding di delphi. Saya asumsikan bahwa anda sudah membuat project, sebuah design form untuk import data dan anda sudah membuat database dengan kriteria tabel database seperti data diatas.

Silahkan tambahkan fungsi dibawah ini untuk memisahkan karakter dari delimiter :

function pilahData(namaFile, Delimiter : string; Kolom : integer) : string;
Temp : TStringList;
Temp := TStringList.Create;
Temp.Text := StringReplace(namaFile, chr(VK_TAB), #13, [rfReplaceAll]);
result := Temp[Kolom];

Langkah selanjutnya yaitu tambahkan 1 buah text edit, 2 buah button dan 1 open dialog yang akan kita gunakan untuk import data dan tambahkan source dibawah ini :

procedure TFMain.Button1Click(Sender: TObject);


if OpenDialog1.Execute then ButtonEdit1.Text := OpenDialog1.FileName;


procedure TFMain.Button2Click(Sender: TObject);
Lines : TStringList;
x : Integer;
Nip, Name, Dept, Grade, Salary : String;

Lines := TStringList.Create;

for x := 0 to Lines.Count -1 do

Nip := pilahData(Lines[x], Chr(VK_TAB), 0);

Name := pilahData(Lines[x], Chr(VK_TAB), 1);

Dept:= pilahData(Lines[x], Chr(VK_TAB), 2);

Grade := pilahData(Lines[x], Chr(VK_TAB), 3);

Salary := pilahData(Lines[x], Chr(VK_TAB), 4);

{Untuk source berikutnya silahkan ekplorasi sendiri sesuai kebutuhan anda.}



Semoga bermanfaat.

10 Responses

  • A lot of thanks for all your valuable hard work on this web page. My daughter delights in working on investigation and it’s obvious why. We all know all concerning the compelling manner you offer rewarding guides through your web site and as well strongly encourage contribution from other ones on this situation plus our favorite simple princess is always studying a lot. Take pleasure in the remaining portion of the new year. You are always conducting a dazzling job.

  • Please, can you PM me and tell me few more thinks about this, I am really fan of your blog…gets solved properly asap.

  • Anyone have a mirror? now that was interesting.

  • Thanks so much for giving me an update on this topic on your blog. Please be aware that if a fresh post appears or if any improvements occur to the current submission, I would be considering reading more and understanding how to make good usage of those methods you discuss. Thanks for your efforts and consideration of other people by making this web site available. resorts in cuba

  • Excellent issues?I’d note that as somebody who actually doesn’t write on blogs a lot (if truth be told, this may be my first post), I don’t think the term ‘lurker’ could be very changing into to a non-posting reader. It’s now not your fault in the least , however perhaps the blogosphere may come up with a better, non-creepy title for the ninety% of us that experience studying the content .

  • We’re a group of volunteers and starting a new scheme in our community. Your web site offered us with valuable information to work on. You’ve done a formidable job and our entire community will be grateful to you.

  • Thanks a lot for being the tutor on this issue. We enjoyed your current article quite definitely and most of all preferred the way in which you handled the areas I widely known as controversial. You happen to be always incredibly kind towards readers really like me and assist me to in my everyday living. Thank you. bytht e qime

  • Thanks so much with regard to giving my family an update on this topic on your site. Please realise that if a brand-new post becomes available or in case any alterations occur with the current posting, I would be interested in reading a lot more and knowing how to make good using of those strategies you talk about. Thanks for your efforts and consideration of other people by making your blog available. Voip Wholesale

  • I’ll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)

  • Took me time to study all the feedback, but I seriously liked the submit. It proved to produce into Fairly beneficial to me and I?m positive to all the commenters right right here It?s usually very good if you can not merely be informed, but in addition entertained I?m certain you had enjoyable writing this submit.

Leave a Reply


Rudi Amirudin, ST.

rSoft. Technologies merupakan sebuah software house yang didirikan oleh Rudi Amirudin, ST. sebagai sarana untuk meningkatkan kreatifitas dalam pembangunan/pengembangan sebuah sistem informasi.