2015-07-01 51 views
0

我可能要對這個錯誤的方式,但這裏的目標:如何使用Java填充預先設計的電子表格?

我想填充特定字段(這些顏色鍵控)在一個電子表格,由用戶輸入兩個數字和那些做出的解決方案投入。電子表格不必是交互式的。實質上,(無法找到解決方案)我試圖將變量傳遞到電子表格中的特定單元格。我可以通過Access或Excel來實現,但這是較大應用程序的一小部分。如果它有幫助,最終,用戶輸入和計算需要存儲在數據庫中並按日期組織/鍵入;每天都會有新的輸入和計算。這裏是我的測試程序:

/* 
    Test program to generate spreadsheet and populate specific cells 
    with the scanner inputs from the user and the solution derived 
    from scanner inputs 
*/ 

import java.util.Scanner; 

class TestRecord { 
    String name; 
    double a; 
    double b; 


    double calc_average() { 
     double x = (a+b)/2; 
     System.out.println("The average is " + x); 
     return x; 
    } 
} 

class SheetGenerator { 

    public static void main(String[] args) { 

    TestRecord dingdong = new TestRecord(); 

     double calculatedAverage; 

     Scanner in = new Scanner(System.in); 

     dingdong.name = "Dipity"; 

     System.out.println("Enter the value the numbers for " +  dingdong.name); 
     System.out.println(); 
     System.out.println("Enter the value for a: "); 
     dingdong.a = in.nextDouble(); 
     System.out.println("Enter the value for b: "); 
     dingdong.b = in.nextDouble(); 

     calculatedAverage = dingdong.calc_average(); 

    } 
} 
+0

你嘗試搜索在Java的電子表格處理庫? (提示:在StackOverflow中,這將是脫離主題)。 – RealSkeptic

回答

1

我已經有很多成功的Apache POI庫。非常容易使用和理解。

特定於Excel和電子表格,使用HSSF & XSSF

相關問題