0
I created this code in Java and is giving error when compiling via CMD:
import java.io.*;
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.write.DateFormat;
import jxl.write.Number;
import jxl.biff.*;
import jxl.write.*;
import java.text.SimpleDateFormat;
class create {
WritableSheet s = workbook.createSheet("Folha1", 0);
WritableSheet s1 = workbook.createSheet("Folha1", 0);
public static void main (String[] args){
try{
/*Seta o arquivo e suas instruções de execução*/
String filename = "test.xls";
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale (new Locale ("en", "EN"));
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
writeDataSheet(s);
writeImageShet(s1);
/*Escreve e Fecha o Arquivo*/
workbook.write();
workbook.close();
}
catch (IOException e){
e.printStackTrace();
}
catch (WriteException e){
e.printStackTrace();
}
}
private static void writeDataSheet (WritableSheet s)throws WriteException; {{
/* Formata a Fonte */
WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
WritableCellFormat cf = new WritableCellFormat (wf);
cf.setWrap (true);
/* Cria um Label e Escreve a Data em Uma Célula da Folha */
Label l = new Label (0,0,"Data",cf);
s.addCell(l);
WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9);
DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT);
s.adCell(dt);
/*Cria um Label e Escreve um Float Numver em Uma Célula da Folha*/
l = new Label(2,0,"Float", cf);
s.addCell(l);
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
Number n = new Number(2,2,-3.1415926535, cf2);
s.addCell(n);
n = new Number(2,2,-3.1415926535, cf2);
s.addCell(n);
/* Cria um label e escreve um float number acima de 3 decimais em uma célula da folha*/
l = new Label(3,0,"3dps",cf);
s.addCell(l);
NumberFormat dp3 = new NumberFormat("#.###");
WritableCellFormat dp3cell = new WritableCellFormat(dp3);
n = new Number(3,1,3.1415926535,dp3cell);
s.addCell(n);
/* Cria um label e adiciona 2 células na folha*/
l = new Label(4, 0, "Add 2 cells",cf);
s.addCell(l);
n = new Number(4,1,10);
s.addCell(n);
n = new Number(4,2,16);
f = new Formula(4,3, "E1+E2");
s.addCell(f);
/* Cria um Label e mulpiplica o valor de uma célula da folha por 2 */
l = new Label(5,0, "Multiplica por 2",cf);
s.addCell(l);
n = new Number(5,1,10);
s.addCell(n);
f = new Formula(5,2, "F1 * 3");
s.addCell(f);
/* Cria um Label e divide o valor de uma célula da folha por 2.5 */
l = new Label(6,0, "Divide por 2,5",cf);
s.addCell(l);
n = new Number(6,1, 12);
s.addCell(n);
f = new Formula(6,2, "F1/2,5");
s.addCell(f);
}
}
private static void WriteImageShet (WritableSheet s)throws WriteException; {{
/* Cria um label e escreve uma imagem em uma célula da folha*/
Label l = new Label(0, 0, "Imagem");
s.addCell(l);
WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));
s.addCell(wi);
/* Cria um label e escreve hyperlink em uma célula da folha*/
l = new Label(0,15, "HiperLink");
s.addCell(l);
Formula f = new Formula(1, 15, "DevMedia(\"http://www.devmedia.com.br\", " + "\"Portal DevMedia\")");
s.addCell(f);
}
}
}
I have read and reread this code and still the error saying that the variables l, f and all the lines that have:
f = new Formula("Argumentos");
l = new Label("Argumentos");
WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));
In all of the 73 errors all of that kind:
error: cannot find Symbol, error: Missing method body or declare Abstract, error: Number is Abstract; cannot be instantiated
in the CMD appears:
Controle_Principal_CSG_teste.java:5: error: package jxl does not exist import jxl.Workbook; ^ Controle_Principal_CSG_teste.java:6: error: package jxl.write does not exist import jxl.write.DateFormat; ^ Controle_Principal_CSG_teste.java:7: error: package jxl.write does not exist import jxl.write.Number; ^ Controle_Principal_CSG_teste.java:17: error: cannot find symbol WritableSheet s = workbook.createSheet("Folha1", 0); ^ symbol: class WritableSheet location: class create Controle_Principal_CSG_teste.java:18: error: cannot find symbol WritableSheet s1 = workbook.createSheet("Folha1", 0); ^ symbol: class WritableSheet location: class create Controle_Principal_CSG_teste.java:52: error: cannot find symbol private static void writeDataSheet (WritableSheet s)throws WriteException; {{ ^ symbol: class WritableSheet location: class create Controle_Principal_CSG_teste.java:52: error: cannot find symbol private static void writeDataSheet (WritableSheet s)throws WriteException; {{ ^ symbol: class WriteException location: class create Controle_Principal_CSG_teste.java:114: error: cannot find symbol private static void WriteImageShet (WritableSheet s)throws WriteException; {{ ^ symbol: class WritableSheet location: class create Controle_Principal_CSG_teste.java:114: error: cannot find symbol private static void WriteImageShet (WritableSheet s)throws WriteException; {{ ^ symbol: class WriteException location: class create Controle_Principal_CSG_teste.java:2: error: package jxl does not exist import jxl.*; ^ Controle_Principal_CSG_teste.java:9: error: package jxl.write does not exist import jxl.write.*; ^ Controle_Principal_CSG_teste.java:17: error: cannot find symbol WritableSheet s = workbook.createSheet("Folha1", 0); ^ symbol: variable workbook location: class create Controle_Principal_CSG_teste.java:18: error: cannot find symbol WritableSheet s1 = workbook.createSheet("Folha1", 0); ^ symbol: variable workbook location: class create Controle_Principal_CSG_teste.java:26: error: cannot find symbol WorkbookSettings ws = new WorkbookSettings(); ^ symbol: class WorkbookSettings location: class create Controle_Principal_CSG_teste.java:26: error: cannot find symbol WorkbookSettings ws = new WorkbookSettings(); ^ symbol: class WorkbookSettings location: class create Controle_Principal_CSG_teste.java:28: error: cannot find symbol WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws); ^ symbol: class WritableWorkbook location: class create Controle_Principal_CSG_teste.java:28: error: cannot find symbol WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws); ^ symbol: variable Workbook location: class create Controle_Principal_CSG_teste.java:29: error: non-static variable s cannot be referenced from a static context writeDataSheet(s); ^ Controle_Principal_CSG_teste.java:30: error: non-static variable s1 cannot be referenced from a static context writeImageShet(s1); ^ Controle_Principal_CSG_teste.java:44: error: cannot find symbol catch (WriteException e){ ^ symbol: class WriteException location: class create Controle_Principal_CSG_teste.java:52: error: missing method body, or declare abstract private static void writeDataSheet (WritableSheet s)throws WriteException; {{ ^ Controle_Principal_CSG_teste.java:57: error: cannot find symbol WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD); ^ symbol: class WritavleFont location: class create Controle_Principal_CSG_teste.java:57: error: cannot find symbol WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD); ^ symbol: class WritableFont location: class create Controle_Principal_CSG_teste.java:57: error: cannot find symbol WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD); ^ symbol: variable WritableFont location: class create Controle_Principal_CSG_teste.java:57: error: cannot find symbol WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD); ^ symbol: variable WritableFont location: class create Controle_Principal_CSG_teste.java:58: error: cannot find symbol WritableCellFormat cf = new WritableCellFormat (wf); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:58: error: cannot find symbol WritableCellFormat cf = new WritableCellFormat (wf); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:62: error: cannot find symbol Label l = new Label (0,0,"Data",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:62: error: cannot find symbol Label l = new Label (0,0,"Data",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:64: error: cannot find symbol WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:64: error: cannot find symbol WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:64: error: cannot find symbol WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9); ^ symbol: variable DateFormats location: class create Controle_Principal_CSG_teste.java:65: error: cannot find symbol DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT); ^ symbol: class DataTime location: class create Controle_Principal_CSG_teste.java:65: error: cannot find symbol DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT); ^ symbol: class DateTime location: class create Controle_Principal_CSG_teste.java:65: error: cannot find symbol DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT); ^ symbol: variable DateTime location: class create Controle_Principal_CSG_teste.java:69: error: cannot find symbol l = new Label(2,0,"Float", cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:71: error: cannot find symbol WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:71: error: cannot find symbol WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:71: error: cannot find symbol WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT); ^ symbol: variable NumberFormats location: class create Controle_Principal_CSG_teste.java:74: error: Number is abstract; cannot be instantiated n = new Number(2,2,-3.1415926535, cf2); ^ Controle_Principal_CSG_teste.java:78: error: cannot find symbol l = new Label(3,0,"3dps",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:80: error: cannot find symbol NumberFormat dp3 = new NumberFormat("#.###"); ^ symbol: class NumberFormat location: class create Controle_Principal_CSG_teste.java:80: error: cannot find symbol NumberFormat dp3 = new NumberFormat("#.###"); ^ symbol: class NumberFormat location: class create Controle_Principal_CSG_teste.java:81: error: cannot find symbol WritableCellFormat dp3cell = new WritableCellFormat(dp3); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:81: error: cannot find symbol WritableCellFormat dp3cell = new WritableCellFormat(dp3); ^ symbol: class WritableCellFormat location: class create Controle_Principal_CSG_teste.java:86: error: cannot find symbol l = new Label(4, 0, "Add 2 cells",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:88: error: no suitable constructor found for Double(int,int,int) n = new Double(4,1,10); ^ constructor Double.Double(double) is not applicable (actual and formal argument lists differ in length) constructor Double.Double(String) is not applicable (actual and formal argument lists differ in length) Controle_Principal_CSG_teste.java:90: error: no suitable constructor found for Double(int,int,int) n = new Double(4,2,16); ^ constructor Double.Double(double) is not applicable (actual and formal argument lists differ in length) constructor Double.Double(String) is not applicable (actual and formal argument lists differ in length) Controle_Principal_CSG_teste.java:91: error: cannot find symbol f = new Formula(4,3, "E1+E2"); ^ symbol: class Formula location: class create Controle_Principal_CSG_teste.java:95: error: cannot find symbol l = new Label(5,0, "Multiplica por 2",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:97: error: no suitable constructor found for Double(int,int,int) n = new Double(5,1,10); ^ constructor Double.Double(double) is not applicable (actual and formal argument lists differ in length) constructor Double.Double(String) is not applicable (actual and formal argument lists differ in length) Controle_Principal_CSG_teste.java:99: error: cannot find symbol f = new Formula(5,2, "F1 * 3"); ^ symbol: class Formula location: class create Controle_Principal_CSG_teste.java:103: error: cannot find symbol l = new Label(6,0, "Divide por 2,5",cf); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:105: error: Number is abstract; cannot be instantiated n = new Number(6,1, 12); ^ Controle_Principal_CSG_teste.java:107: error: cannot find symbol f = new Formula(6,2, "F1/2,5"); ^ symbol: class Formula location: class create Controle_Principal_CSG_teste.java:114: error: missing method body, or declare abstract private static void WriteImageShet (WritableSheet s)throws WriteException; {{ ^ Controle_Principal_CSG_teste.java:118: error: cannot find symbol l = new Label(0, 0, "Imagem"); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:120: error: cannot find symbol WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png")); ^ symbol: class WriteableImage location: class create Controle_Principal_CSG_teste.java:120: error: cannot find symbol WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png")); ^ symbol: class WriteableImage location: class create Controle_Principal_CSG_teste.java:124: error: cannot find symbol l = new Label(0,15, "HiperLink"); ^ symbol: class Label location: class create Controle_Principal_CSG_teste.java:126: error: cannot find symbol f = new Formula(1, 15, "DevMedia(\"http://www.devmedia.com.br\", " + "\"Portal DevMedia\")"); ^ symbol: class Formula location: class create 61 errors
no need to apologize there are several gigantic posts and all with the same purpose, the idea is to learn, remembering that the more information you have about what you are doing better, it is simpler to identify the mistakes
– Daniel Gentil
n = new Number(3,1,3.1415926535,dp3cell);
this ta wrong, Number is not an instantiative type. You need to choose whether it is Double, Float, Integer. Number can not.– user28595
I switched the ones with the numbers with . type what you put above 3.14159... reduced the errors now have 61 now only with errors in what has the new Label and the new Formula
– Shintaro
Can’t tell if you don’t show errors and where they occur. Edit the question and provide more information.
– user28595
you can post what you’re showing in cmd?
– Shintaro
Yes, but add to the question by clicking EDIT.
– user28595
Was abandoned '-'
– Shintaro
@Bitsofbytes I’ve come to save you
– Jéf Bueno
@LINQ can understand what’s giving the error?
– Shintaro
@Bitsofbytes Yes and I already answered
– Jéf Bueno