Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java | MS Excell
28-07-2012, 02:57 PM,
Post: #1
Java | MS Excell
Hurm ;b ada tak sample kod java yang bleh baca data dari column + rows dalam excell dan boleh ubah / tulis data balik dalam excell tu.

Tak mahu guna trik ODBC.
Aku dev guna esclipse, ada ke apa2 komponen khas aku bleh guna?
cc : @[s3m00t] @[johnburn]
We live among its people now, hiding in plain sight... but watching over them in secret... waiting... protecting. I have witnessed their capacity for courage, and though we are worlds apart, like us, there's more to them than meets the eye..
Reply
28-07-2012, 04:37 PM, (This post was last modified: 28-07-2012, 09:22 PM by lamki.)
Post: #2
RE: Java | MS Excell
aku pakai ni jxl API...download kat http://jexcelapi.sourceforge.net/ ...
aku pnah gner utk read dri .xls je...tp klu nk write blik boleh je kot...
______________________________________________________

sample :


Code:
import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.*;
import java.util.StringTokenizer;
import java.sql.*;
import java.util.*;

public class ReadExcelDB2 {
    private String inputFile;
    public void setInputFile(String inputFile) {
        this.inputFile = inputFile;
    }
    public void read() throws IOException{
        File inputWorkbook = new File(inputFile);
        Workbook w;
        int i=0,s=1;
            try{
            w = Workbook.getWorkbook(inputWorkbook);
            // Get the first sheet
            Sheet sheet = w.getSheet(0);
            // Loop over first 10 column and lines
            //                      c,r
            Cell a1 = sheet.getCell(0,0);
            String s1 = a1.getContents();

            for(int k=0; k < sheet.getRows();k++){
              for(int j=3; j < sheet.getColumns();j++)
              {
                Cell m = sheet.getCell(j,k);
                String l = m.getContents();
                if(!l.equals(""))
                {System.out.print("\n\n Isi perut dalam kolumn"+l);
                }}}      
        }catch (BiffException e) {
         }}
    public static void main(String[] args) throws IOException {
            ReadExcelDB2 test = new ReadExcelDB2();
            test.setInputFile("contoh4.xls");
            test.read();
    }}

yg pelik2 skit tu ignore je ^^
Revenge 101 :
Spoiler:

1.Pee in plate
2.Freeze the pee(in 1.)
3.Slide frozen 'pee disc' under the victim's door(room or house, any will do)
4.The pee disc will now melt.
5.???
6.Profit

Hmm
Reply
28-07-2012, 07:54 PM, (This post was last modified: 28-07-2012, 07:54 PM by cupin06.)
Post: #3
RE: Java | MS Excell
guna jxl framework.Boleh read,write

contoh ko leh import

Code:
import jxl.Cell;
import jxl.Sheet;
import jxl.write.*;
import jxl.Workbook;
import jxl.WorkbookSettings;


[Image: Untitled-1.png]
Reply
28-07-2012, 08:37 PM,
Post: #4
RE: Java | MS Excell
aku tak pernah buat. so, tak de lah sample source code. Sad tapi, maybe kau boleh try guna satu idea ni. aku pernah buat untuk ms word sbb dulu saja try nak buat library walaupun x jadi. Auch

kau uncompress file .xls guna winrar. dalam folder yang dah di uncompress tu, akan ada beberapa buah folder + file seperti xml dan sebagainya. so, kau buat lah try & error untuk belajar format susunan data dalam file tersebut. daripada situ, insyaAllah kau boleh dapat data-data yang disimpan.

bab nak ubah tu mungkin boleh. cuma, aku tak pasti compression algorithm apa yang dia guna untuk hasilkan .xls. apa-apa pun, ini idea untuk buat manual tanpa guna sebarang thrid party library lah. Smile
Reply
28-07-2012, 11:04 PM,
Post: #5
RE: Java | MS Excell
Apache POI & JExcelApi hurmm..
jap, jexcelapi ni bleh baca format opis excell 2007 x @[#l0u7]?
We live among its people now, hiding in plain sight... but watching over them in secret... waiting... protecting. I have witnessed their capacity for courage, and though we are worlds apart, like us, there's more to them than meets the eye..
Reply
29-07-2012, 12:41 AM,
Post: #6
RE: Java | MS Excell
(28-07-2012, 11:04 PM)127.0.0.1 Wrote: Apache POI & JExcelApi hurmm..
jap, jexcelapi ni bleh baca format opis excell 2007 x @[#l0u7]?

xley...dy bley bce .xls je...

Revenge 101 :
Spoiler:

1.Pee in plate
2.Freeze the pee(in 1.)
3.Slide frozen 'pee disc' under the victim's door(room or house, any will do)
4.The pee disc will now melt.
5.???
6.Profit

Hmm
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Soalan Java darknite 10 847 27-11-2013, 01:47 PM
Last Post: darknite
  soalan java. hard3 4 954 10-05-2013, 10:33 PM
Last Post: JejakaPemalu
  [help] inputfile java please click me to know more Timon 0 400 14-04-2013, 10:02 PM
Last Post: Timon
  [problem]with java tcp client and server chat pron3t 1 575 26-02-2013, 01:21 PM
Last Post: muhaznar
  java API Timon 3 861 09-12-2012, 09:58 PM
Last Post: lamki
  java background music library Timon 0 466 09-12-2012, 05:21 PM
Last Post: Timon
  JAVA Layout... mana 1 feveret :P 127001 7 1,719 03-12-2012, 10:32 AM
Last Post: Wushipher
  Tutorial: Menghubungkan SQLite Dengan Java s3m00t 4 1,329 25-07-2012, 02:40 AM
Last Post: s3m00t
  [java prob]guna user input dan methode erroe indintifier pron3t 2 678 22-04-2012, 07:56 PM
Last Post: pron3t
  [Tut]Java Array Name Ujang 2 746 19-04-2012, 03:07 PM
Last Post: pron3t

Forum Jump: