finetuned the export feature
This commit is contained in:
@@ -16,6 +16,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
@@ -154,9 +155,21 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
||||
*/
|
||||
private boolean exportToCSV() {
|
||||
if(fc.showDialog(SearchDialog.this, "Export") == JFileChooser.APPROVE_OPTION){
|
||||
//prep the data for proper csv format
|
||||
StringBuffer sb = new StringBuffer("Order Number,Time & date,Product Name,Order Amount,Amount Charged,Financial Status,Fulfillment Status,Customer Name,Customer Email");
|
||||
sb.append(mOrderPanel.getText());
|
||||
|
||||
Scanner scan = new Scanner(mOrderPanel.getText());
|
||||
String[] parts;
|
||||
String line;
|
||||
while(scan.hasNext()){
|
||||
line = scan.nextLine();
|
||||
parts = line.split(",");
|
||||
try {
|
||||
sb.append(parts[0].substring(1)+","+parts[1].substring(1)+","+parts[2].substring(1)+","+parts[3].substring(1)+","+parts[4].substring(1)+","+parts[5].substring(1)+","+parts[6].substring(1)+","+parts[7].substring(1)+","+parts[8].substring(1)+"\n");
|
||||
} catch (Exception e) {
|
||||
sb.append(line+"\n");
|
||||
}
|
||||
}
|
||||
//write to the selceted file
|
||||
try {
|
||||
FileOutputStream theFile;
|
||||
if (fcCheckBox.isSelected())
|
||||
@@ -214,7 +227,6 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
||||
mOrderPanel.setOnProgressListerner(SearchDialog.this);
|
||||
mOrderPanel.displayOrders(list);
|
||||
|
||||
//todo updates order panel
|
||||
isProcessing = false;
|
||||
|
||||
pack();
|
||||
|
||||
Reference in New Issue
Block a user