怎么把java代码导出来 java怎么导入

如何将Eclipse中编写的java项目导出?

1.导入项目

创新互联建站主要从事网站制作、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务郊区,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

当下载了包含Eclipse 项目的源代码文件后,我们可以把它导入到当前的Eclipse 工作区然后编辑和查看。点击菜单File Import,然后在弹出的Import 对话框中展开General目录,选择Existing Projects into Workspace,接着点击Next 按钮。当选中单选钮Select root directory:时可以点击Browse…按钮选中包含项目的文件夹,如果包含项目的话就可以在中间的Projects 列表框中显示;而当选中单选钮Select archive file:时可以点击Browse…按钮选中包含项目的ZIP 压缩包,如果包含项目的话就可以在中间的Projects列表框中显示。最后点击Finish 按钮就可以导入项目并打开了。

2.导出项目

点击菜单File Export,然后在弹出的Export 对话框中展开General 目录,选择Archive File,接着点击Next 按钮。然后在To archive file:输出框中选中要保存的文件名,一般写成项目名.zip,然后点击Finish 按钮即可导出当前项目。还有一种方式是手工打包,用WinRAR 或者WinZIP 等工具都可以。

java代码怎么导出excel文件

excel工具类

package com.ohd.ie.product.action;

import java.awt.image.BufferedImage;

import java.io.*;

import javax.imageio.ImageIO;

import org.apache点抗 mons.io.output.ByteArrayOutputStream;

import jxl.Workbook;

import jxl.format.Alignment;

import jxl.format.VerticalAlignment;

import jxl.write.*;

import jxl.write.Number;

import jxl.write.biff.RowsExceededException;

public class Excel {

private OutputStream os;

private WritableWorkbook wwb = null;

private WritableSheet ws = null;

private WritableCellFormat titleCellFormat = null;

private WritableCellFormat noBorderCellFormat = null;

private WritableCellFormat hasBorderCellFormat = null;

private WritableCellFormat hasBorderCellNumberFormat = null;

private WritableCellFormat hasBorderCellNumberFormat2 = null;

private WritableImage writableImage=null;

private int r;

public Excel(OutputStream os){

this.os = os;

r = -1;

try {

wwb = Workbook.createWorkbook(os);

//创建工作表

ws = wwb.createSheet("sheet1",0);

//设置表头字体,大小,加粗

titleCellFormat = new WritableCellFormat();

titleCellFormat.setAlignment(Alignment.CENTRE);

titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);

//自动换行

titleCellFormat.setWrap(true);

titleCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12,WritableFont.BOLD));

titleCellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);

//设置表格字体,大小----无边框

noBorderCellFormat = new WritableCellFormat();

noBorderCellFormat.setAlignment(Alignment.CENTRE);

noBorderCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);

noBorderCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));

//设置表格字体,大小----有边框

hasBorderCellFormat = new WritableCellFormat();

hasBorderCellFormat.setAlignment(Alignment.CENTRE);

hasBorderCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);

hasBorderCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));

hasBorderCellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);

//设置表格字体,大小----有边框(小数)

NumberFormat nf = new NumberFormat("#0.00");

hasBorderCellNumberFormat = new WritableCellFormat(nf);

hasBorderCellNumberFormat.setAlignment(Alignment.CENTRE);

hasBorderCellNumberFormat.setVerticalAlignment(VerticalAlignment.CENTRE);

hasBorderCellNumberFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));

hasBorderCellNumberFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);

//设置表格字体,大小----有边框(整数)

NumberFormat nf2 = new NumberFormat("#0");

hasBorderCellNumberFormat2 = new WritableCellFormat(nf2);

hasBorderCellNumberFormat2.setAlignment(Alignment.CENTRE);

hasBorderCellNumberFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);

hasBorderCellNumberFormat2.setFont(new WritableFont(WritableFont.createFont("宋体"),12));

hasBorderCellNumberFormat2.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

*

* @param content 内容

* @param c 列

* @param style 样式

* @param isNewLine 是否换行

* @param mergeType 合并类型

* @param mergeCount 合并个数

* @param width 单元格宽

*/

public void setExcelCell(String content,int c,int style,boolean isNewLine,int mergeType,int mergeCount,int width){

try {

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////报表内容////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

if(isNewLine){

r++;

}

WritableCell l = null;

if(style == 1){

l = new Label(c,r,content,titleCellFormat);

}

else if(style == 2){

l = new Label(c,r,content,noBorderCellFormat);

}

else if(style == 3){

l = new Label(c,r,content,hasBorderCellFormat);

}

else if(style == 4){

l = new Number(c,r,Double.parseDouble(content),hasBorderCellNumberFormat);

}

else if(style == 5){

l = new Number(c,r,Integer.parseInt(content),hasBorderCellNumberFormat2);

}

ws.addCell(l);

if(width != 0){

ws.setColumnView(c,width);

}

//veryhuo,com

if(mergeType == 1){

//x 轴方向

ws.mergeCells(c, r, c+mergeCount-1 , r);

}

else if(mergeType == 2){

//y 轴方向

ws.mergeCells(c, r, c, r+mergeCount-1);

}

if(isNewLine){

ws.setRowView(r, 350);

if(style == 1 r != 0){

ws.setRowView(r, 900);

}

else{

ws.setRowView(r, 350);

}

}

//

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

} catch (Exception e) {

System.out.println(e.toString());

}

}

public void setExcelCellEx(String content,int c,int style,boolean isNewLine,int mergeType,int mergeCount,int width,int row){

try {

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////报表内容////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

if(isNewLine){

r++;

}

WritableCell l = null;

if(style == 1){

l = new Label(c,r,content,titleCellFormat);

}

else if(style == 2){

l = new Label(c,r,content,noBorderCellFormat);

}

else if(style == 3){

if(content.indexOf(".jpg")!=-1 ||content.indexOf(".JPG")!=-1){

File outputFile=null;

File imgFile =new File(content);

if(imgFile.exists()imgFile.length()0){

BufferedImage input=null;

try {

input = ImageIO.read(imgFile);

} catch (Exception e) {

e.printStackTrace();

}

if(input!=null){

String path=imgFile.getAbsolutePath();

outputFile = new File(path.substring(0,path.lastIndexOf('.')+1)+"png");

ImageIO.write(input, "PNG", outputFile);

if(outputFile.exists()outputFile.length()0){

ws.setRowView(row,2000);

//ws.setColumnView(8, 10);

writableImage = new WritableImage(c+0.1, row+0.1, 0.8, 0.8, outputFile);

ws.addImage(writableImage);

l = new Label(c,r,"",hasBorderCellFormat);

}

}

}

}else{

l = new Label(c,r,content,hasBorderCellFormat);

}

}

else if(style == 4){

l = new Number(c,r,Double.parseDouble(content),hasBorderCellNumberFormat);

}

else if(style == 5){

l = new Number(c,r,Integer.parseInt(content),hasBorderCellNumberFormat2);

}

ws.addCell(l);

if(width != 0){

ws.setColumnView(c,width);

}

if(mergeType == 1){

//x 轴方向

ws.mergeCells(c, r, c+mergeCount-1 , r);

}

else if(mergeType == 2){

//y 轴方向

ws.mergeCells(c, r, c, r+mergeCount-1);

}

if(isNewLine){

ws.setRowView(r, 350);

if(style == 1 r != 0){

ws.setRowView(r, 900);

}

else{

ws.setRowView(r, 350);

}

}

} catch (Exception e) {

System.out.println(e.toString());

}

}

public void setRowHeight(int val){

try {

ws.setRowView(r, val);

} catch (RowsExceededException e) {

e.printStackTrace();

}

}

public void getExcelResult(){

try {

wwb.write();

} catch (Exception e) {

System.out.println(e.toString());

}

finally{

if(wwb != null){

try {

wwb.close();

if(os != null){

os.close();

}

} catch (WriteException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

}

需要的jar包:jxl.jar

java项目 如何把代码导出来,导成.doc格式的文档。急。具体方法,废话少说、

我用的eclipse,选中项目,右键-export-java-doc-next就这样就导出了,导出的是网页形式的注释说明文档,想要导出doc格式的文档那是不行的。

java代码怎样运行出来?

步骤:

1、在cmd中切换到编写的代码所保存的目录下;

2、在cmd中输入javac然后点空格,再点击文件名和包括后缀名确定后,在存放编写代码的文件下会生成一个class的字节码文件;

3、在cmd中输入java然后点空格,输入第二步中生成的字节码的文件名,不需要后缀名,点击确定即可运行代码。

代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。计算机代码称为源代码,是相对目标代码和可执行代码而言的。 源代码就是用汇编语言和高级语言写出来的地代码,目标代码是指源代码经过编译程序产生的能被cpu直接识别二进制代码。


当前名称:怎么把java代码导出来 java怎么导入
文章起源:http://scyanting.com/article/ddjggjg.html