struts2+extjs上传excel文件的问题

struts2+extjs上传excel文件的问题,第1张

给你extjs能执行的你研究一下

我觉得你设置 xtype: 'filefield', 能好用

*************************************************************************

*上传框组件

*

************************************************************************

*/

Ext.define('Mocoolka.web.coreview.container.MKUploadForm', {

extend:'Ext.form.Panel',

frame: true,

autoScroll: true,

initComponent: function () {

var me = this

me.title = getUIWithID("SystemUI.Buttons.Upload.Description")//'上传',

me.items = [

{

xtype: 'filefield',

emptyText: getUIWithID("SystemUI.MKUploadForm.SelectFile.Description"),//'选择一个文件',

name: 'filename',

buttonText: '...',

buttonConfig: {

iconCls: 'upload-icon'

}

},

]

me.buttons = [{

text: getUIWithID("SystemUI.Buttons.Upload.Description"),//'上传',

handler: function () {

var form = this.up('form').getForm()

var action = this.up('form').mkaction

var myaction = "import"

if (action.get("Name") == "ImportAttachment")

myaction = "ImportAttachment"

var url = mkruntimer.getDataManager().getUrlPath(myaction, action)

if (form.isValid()) {

form.submit({

url: url,

waitMsg: getUIWithID("SystemUI.Buttons.Uploading.Description"),//'上传中...',

success: function (fp, o) {

var form1 = form.owner

form1.mkcallout(form1.mkcalloutpara, action.result.children)

form1.up('window').close()

},

failure: function (form, action) {

mkerrorutil.processAjaxFailure(action.response)

}

})

}

}

}, {

text: getUIWithID("SystemUI.Buttons.Reset.Description"),//'重设',

handler: function () {

this.up('form').getForm().reset()

}

}, {

text: getUIWithID("SystemUI.Buttons.Cancel.Description"),//'取消',

handler: function () {

this.up('window').close()

}

},

{

text: getUIWithID("SystemUI.MKUploadForm.AddFile.Description"),//'增加一个文件',

handler: function () {

this.up('form').addFile()

}

}

]

me.callParent(arguments)

},

addFile: function () {

var me = this

me.add({

xtype: 'filefield',

emptyText: getUIWithID("SystemUI.MKUploadForm.SelectFile.Description"),//'选择一个文件',

fieldLabel: getUIWithID(""),// '文件',

name: 'filename',

buttonText: '',

buttonConfig: {

iconCls: 'upload-icon'

}

})

},

//standardSubmit:false,

bodyPadding: '10 10 0',

flex:1,

defaults: {

anchor: '100%',

msgTarget: 'side',

labelWidth: 50

},

region: 'center',

})

/**

* readExcel

* suport: excel95-2003

* except: excel2010

* @param excelInputStream 文件

* @param sheetOrder 第一个为0

* @return 全部行

* @需要jar包:jxl.jar

*/

public static List<String[]>readExcel95_2003(InputStream excelInputStream, int sheetOrder) {/*jxl.jar*/

List<String[]>excelValueList = new ArrayList<String[]>()

Workbook workbook = null

try {

workbook = Workbook.getWorkbook(excelInputStream)

//read sheet

Sheet sheet = workbook.getSheet(sheetOrder)

//get rows

int row = sheet.getRows()

int col = sheet.getColumns()

for (int i = 0i <rowi++) {

String[] rowVal = new String[col]

for (int j = 0j <colj++) {

rowVal[j] = sheet.getCell(j, i).getContents()

rowVal[j] = rowVal[j] == null?"":rowVal[j]

}

excelValueList.add(rowVal)

}

} catch (BiffException e) {

excelValueList = null

e.printStackTrace()

} catch (IOException e) {

excelValueList = null

e.printStackTrace()

} finally {

if(excelInputStream!=null) {

try {

excelInputStream.close()

} catch (IOException e) {

e.printStackTrace()

}

}

if (workbook!=null) {

workbook.close()

}

}

return excelValueList

}

创建数据库

选择

开始菜单

中→程序→【Management

SQL

Server

2008】→【SQL

Server

Management

Studio】命令,打开【SQL

Server

Management

Studio】窗口,并使用Windows或

SQL

Server

身份验证

建立连接。

在【对象

资源管理器

】窗口中展开服务器,然后选择【数据库】节点

右键单击【数据库】节点,从d出来的

快捷菜单

中选择【新建数据库】命令。

执行上述 *** 作后,会d出【新建数据库】对话框。在对话框、左侧有3个选项,分别是【常规】、【选项】和【

文件组

】。完成这三个选项中的设置会后,就完成了数据库的创建工作,

在【数据库名称】

文本框

中输入要新建数据库的名称。例如,这里以“新建的数据库”。

在【所有者】文本框中输入新建数据库的所有者,如sa。根据数据库的使用情况,选择启用或者禁用【使用

全文索引

复选框

在【

数据库文件

】列表中包括两行,一行是数据库文件,而另一行是日记文件。通过单击下面的【添加】、【删除】按钮添加或删除数据库文件。

切换到【选项页】、在这里可以设置数据库的排序规则、恢复模式、兼容级别和其他属性。

切换到【文件组】页,在这里可以添加或

删除文件

组。

完成以上 *** 作后,单击【确定】按钮关闭【新建数据库】对话框。至此“新建的数据”数据库创建成功。新建的数据库可以再【对象资源管理器】窗口看到。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/11893510.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存