第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將我的輸入保存到電子表格?

如何將我的輸入保存到電子表格?

冉冉說 2022-07-27 20:55:04
我希望我的員工在每天結(jié)束時填寫此信息。我如何能夠?qū)⒚刻斓臄?shù)據(jù)保存到新的電子表格中?有一天,我也會嘗試制作一個易于使用的 UI。順便說一句,它還沒有完成,仍然需要添加一種方法來保存一天的兩組數(shù)據(jù),因為可能有兩個騎手在同一天工作。并且還沒有任何錯誤檢測。public static void main(String[] args) {    //<---Declaring input method        Scanner scan = new Scanner(System.in);      //<---Declaring Variables        String Rider;        int SLetters;        int LLetters;        int SParcels;        int LParcels;        int RedirectedMail;        int RTSMail;        int SigItems;        int VSortStart;        int VSortFinish;        int SetupTimeBeat1Parcels;        int SetupTimeBeat2Parcels;        int SetupTimeBeat3Parcels;        int SetupTimeMainStParcels;        int SetupTimeLargeParcels;        int SetupTimeBeat1Letters;        int SetupTimeBeat2Letters;        int SetupTimeBeat3Letters;        int SetupTimeMainStLetters;        int DeliveryStartTime;        int DeliveryFinishTime;        int LargeParcelDeliveryStart;        int LargeParcelDeliveryFinish;        int BikeDistanceStart;        int BikeDistanceFinish;        int CarDistanceStart;        int CarDistanceFinish;        int Breaks;        int ConfirmCount = 0;    //<---Asking for User input and collecting the data    //<---While loop to make sure data is correct        while(ConfirmCount == 0) {            System.out.print("Enter number of Small Letters: ");            SLetters = scan.nextInt();            System.out.print("Enter number of Large Letters: ");            LLetters = scan.nextInt();            System.out.print("Enter number of Small Parcels: ");            SParcels = scan.nextInt();            System.out.print("Enter number of Large Parcels: ");            LParcels = scan.nextInt();            System.out.print("Enter number of Redirected Letters: ");            RedirectedMail = scan.nextInt();            System.out.print("Enter number of RTS Letters: ");            RTSMail = scan.nextInt();
查看完整描述

2 回答

?
拉風的咖菲貓

TA貢獻1995條經(jīng)驗 獲得超2個贊

您可以借助APACHE POI將您的輸入寫入電子表格。

在這里查看 - https://www.tutorialspoint.com/apache_poi/apache_poi_spreadsheets.htm

簡而言之,該邏輯將幫助您將電子表格添加到現(xiàn)有的 excel 文件中。

HSSFWorkbook workbook = null; // creating a new workbook

File file = new File(context.getExternalFilesDir(null), "Sample.xls"); //getting a file with this name if not exist will create a new excel file with this in below steps

FileOutputStream fileOut = new FileOutputStream(file); // output stream is used to write to a file


if (file.exists()) { // if file exists add a new workbook to it 

    try {

        workbook = (HSSFWorkbook)WorkbookFactory.create(file);

    } catch (InvalidFormatException e) {

        e.printStackTrace();

    }

    //add logic to convert the input to excel rows and write it into a wrokbook like this

    HSSFSheet sheet = workbook.createSheet("Sample sheet2");


}

else{ // create a new workbook

    workbook = new HSSFWorkbook();

    // for the first time if nothing is there this will execute 

    //add logic to convert the input to excel rows and write it into a wrokbook like this

    HSSFSheet sheet = workbook.createSheet("Sample sheet1");

}

workbook.write(fileOut); // closing the workbook after all operations

fileOut.close(); // closing the output stream

如果您對 JAVA 不太熟悉,這可能看起來有點復雜,但我建議您在此處提出任何不合理的問題。


查看完整回答
反對 回復 2022-07-27
?
慕村9548890

TA貢獻1884條經(jīng)驗 獲得超4個贊

可以使用poi相關的依賴,就像這樣


 WritableWorkbook book = Workbook.createWorkbook(new File("c:\\test.xls"));

 WritableSheet sheet = book.createSheet("sheet1", 0);

 Label label = new Label(0, 0, "test");

 sheet.addCell(label);

 jxl.write.Number number = new jxl.write.Number(1, 0, 555.12541);

 sheet.addCell(number);

 book.write();

 book.close();

這個可以編輯windows excel,可以通過google了解poi相關操作。當然,我認為更好的方法是通過 javaEE 創(chuàng)建一個 Web 項目


查看完整回答
反對 回復 2022-07-27
  • 2 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號