मैं एक्सेल शीट मान पढ़ना चाहता हूं और उन मानों को जावा में सरणी में संग्रहीत करना चाहता हूं।एक्सेल में एक्सेल फ़ाइल और स्टोर से मूल्य कैसे पढ़ा जाए?
मेरे पास एक्सेल शीट पढ़ने के लिए कोड तैयार है लेकिन मैं उन मानों को ऐरे में संग्रहीत करने के लिए इसे अनुकूलित करने में सक्षम नहीं हूं।
package com.core.testscripts;
import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class NewExcel
{
private String inputFile;
public void setInputFile(String inputFile)
{
this.inputFile = inputFile;
}
public void read() throws IOException
{
File inputWorkbook = new File(inputFile);
Workbook w;
try
{
w = Workbook.getWorkbook(inputWorkbook);
// Get the first sheet
Sheet sheet = w.getSheet(0);
// Loop over first 10 column and lines
for (int j = 0; j < sheet.getColumns(); j++)
{
for (int i = 0; i < sheet.getRows(); i++)
{
Cell cell = sheet.getCell(j, i);
System.out.println(cell.getContents());
}
}
}
catch (BiffException e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException
{
NewExcel test = new NewExcel();
test.setInputFile("D:/hellohowareyou.xls");
test.read();
}
}
कैसे आप पढ़ सकते हैं करना चाहते हैं? एक ही सरणी में सभी पंक्तियों की सभी कोशिकाएं? या दो आयामी सरणी में प्रति पंक्ति सभी कोशिकाओं ?? – Nik