|
|
| Java compilation error |
Expert:Bill Swann
I place the following code in to my program but get a compile error of cannot resolve symbol on this code - fullFileName.append(vendorID) vendorID is a parameter. What am I doing wrong.
public void writeWorkbookToFile() { // create the full path & file name: StringBuffer fullFileName = new StringBuffer(SPREADSHEETPATH); fullFileName.append("/"); fullFileName.append(SPREADSHEETFILENAME); fullFileName.append("-"); fullFileName.append(FileYearMonth); fullFileName.append(vendorID); // add the ".XLS" Excel extension to the file name: fullFileName.append(SPREADSHEETEXTENSION); |
| Answers |
Hi friend,
Plz give full source code to solve the problem :
Thanks
|
Here is the source code. /* * Created on Dec 2, 2008 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */
import burlington.files.Vndslrdl0; import java.sql.*; import java.io.*;
/** * Create the monthly Vendor Service Level spreadsheet file. * @author Gerry McLaughlin clone by Bill Swann * to create use this command in qshell - javac -classpath /home/java/build/ ServiceLevelReport1.java */ public class ServiceLevelReport1{
private ResultSet queryResults; private ExcelSpreadSheet spreadsheet; public static final String TEMPLATEPATHANDFILENAME = "/home/mis/VendorIMA/GSK/GSKSvcLvlTemplate.xls"; private static final String SPREADSHEETPATH = "/home/mis/VendorIMA/ADJ"; private static final String SPREADSHEETFILENAME = "BDrug_ServiceLevelReport"; private static final String SPREADSHEETEXTENSION = ".XLS"; private String FileYearMonth = ""; private FileInputStream templateFile; /** * main - run the ServiceLevelReport with default. * @param args */ public static void main(String[] args) { if (args != null) { if (args.length >= 2) { try{ new ServiceLevelReport1(args[0],args[1] ); } catch(Exception ex1) { ex1.printStackTrace(); } } } else { try{ new ServiceLevelReport1(); } catch(Exception e) { e.printStackTrace(); } }
} /** * default constructor - create Monthly Spreadsheet file for * the default Glaxo Smithkline vendor " 001267" and Aug, 2005. * */ public ServiceLevelReport1() { this(" 001267","200508"); } /** * Create monthly Service Level Report spreadsheet file using the * vendor# and year/month passed. * @param vendorID * @param Year/month - 6 character string. */ public ServiceLevelReport1 (String vendorID, String YearMonth) { super(); cloneTemplateSpreadsheet(); queryFile(vendorID,YearMonth); populateSpreadSheet(); writeWorkbookToFile(); } private void queryFile(String vendorID, String YearMonth) { try { queryResults = Vndslrdl0.runQuery_getData(vendorID,YearMonth); } catch (SQLException e) { e.printStackTrace(); } } /** * put the contents of the query result set into the spread sheet object. * */ private void populateSpreadSheet() { int row = 0; Object[] obj = new Object[11]; // read the query results and add to spreadsheet: try { while (queryResults.next ()) { obj[0] = queryResults.getString("SLRYRMO"); obj[1] = queryResults.getString("SLRNDC#"); obj[2] = queryResults.getString("SLRDESC"); // spreadsheet cells can't hold a BigDecimal, so transform the BigDecimal // returned from the iSeries DB2 query results into a Double. obj[3] = new Double( queryResults.getBigDecimal("SLRDMND").toString() ); obj[4] = new Double( queryResults.getBigDecimal("SLRLSHP").toString() ); obj[5] = new Double( queryResults.getBigDecimal("SLRLSRT").toString() ); obj[6] = new Double( queryResults.getBigDecimal("SLRSLVL").toString() ); obj[7] = new Double( queryResults.getBigDecimal("SLRLNBO").toString() ); obj[8] = new Double( queryResults.getBigDecimal("SLRSLVA").toString() ); obj[9] = " "; obj[10] = queryResults.getString("SLRNOTE"); row = row + 1; // use the first row's Year/Month field to populate the // year & month part of the file name. if (row == 1) { FileYearMonth = obj[0].toString(); } spreadsheet.putDataInRow(row,obj); } } catch (SQLException e) { e.printStackTrace(); } } /** * create a new excel file from workbook. */ public void writeWorkbookToFile() { // create the full path & file name: StringBuffer fullFileName = new StringBuffer(SPREADSHEETPATH); fullFileName.append("/"); fullFileName.append(SPREADSHEETFILENAME); fullFileName.append("-"); fullFileName.append(FileYearMonth); // fullFileName.append(vendorID); // add the ".XLS" Excel extension to the file name: fullFileName.append(SPREADSHEETEXTENSION); FileOutputStream file_Out; try { file_Out = new FileOutputStream(fullFileName.toString()); spreadsheet.writeWorkBookToFileOutPutStream(file_Out ); // System.out.println("file created"); } catch (Exception e) { e.printStackTrace(); } } /** * create a new empty spreadsheet from the GSK 830 template Excel spreadsheet file. * */ private void cloneTemplateSpreadsheet() { // create the FileInputStream from the string representing the template excel file. try { templateFile = new FileInputStream(TEMPLATEPATHANDFILENAME); } catch (FileNotFoundException e) { e.printStackTrace(); } // create the spreadsheet from the FileInputStream: try { spreadsheet = new ExcelSpreadSheet(templateFile); } catch (IOException e1) { e1.printStackTrace(); } } }
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|