解决方案 »
- jquery选择器问题
- 关于网页内容链接,很头痛的问题....请大家帮帮我。
- JS如何创建时间对象
- 用javascript做一个类,类字段根据参数来定义,是否不能做任何运算
- 如何用静态页面存储一些简单的数据?
- 求助 js正则未结束的js代码浏览器卡死
- 我要用confirm做弹出框,弹出之后原来的那一页也要显示。应怎样写?
- 在c中嵌入javascript的问题!
- 修改disabled属性时,为何onpropertychange事件只有在设置 disabled=true 时才发生?
- 有没有和trello类似的看板工具?
- javascript 在不同的服务器上运行的问题
- jquery中的click如何传递不同的参数?
function f_excel() {var f = window.document.form1;if(!valid(form1)) return;
f.target = "hidden";
f.action = "/servlet/DownloadSVL?cmd=lass.dispute.mgt.cmd.DisputeRelatedDebtToExcelCMD";
f.submit();f.target = "detail";
f.action = "/servlet/JspChannelSVL?cmd=lass.dispute.mgt.cmd.RetrieveDisputeRelatedDebtListCMD";
}
function convertCSV(fileLink, fileName, filePassword) {// browser detection
if (navigator.appName != "Microsoft Internet Explorer") {
alert("This service is Internet Explorer Only");
return false;
}// validation
if (!validate(fileName, filePassword)) return false;// Create Excel Object
try {
var Excel = new ActiveXObject("Excel.Application");} catch (E) {
alert("To enable this service, confirm your browser security setting: " +
"Tools→Internet Options→Security→Custom Level→ActiveX Controls and plug-ins→Initialize and script ActiveX controls not maked ... " +
"should be checked as [Enable] or [Prompt]");
return false;
}try {
// Convert XLSX/CSV -> XLSX
var ExcelWorkbook = Excel.Workbooks.Open(fileLink, false);
ExcelWorkbook.SaveAs(fileName, 51, filePassword);
// 51 = File Format number for OpenXML Excel Workbook Spreadsheet (xlOpenXMLWorkbook = 51)
// For more information, follow the link: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlfileformat.aspx} catch(E) {
alert(" invalid CSV file link or conversion error)");
Excel.Application.Quit();
return false;
}Excel.Application.Quit();
return true;
}
function validate(fileName, filePassword) {// field / argument validation
if (filePassword == "") {
alert(" Password is empty");
return false;
}if (fileName == "" || fileName == null) {
alert("invalid file name)");
return false;
} else if (fileName.length < 6 || getExtension(fileName) != ".xlsx") {
fileName += ".xlsx";
}return true;
}
function getExtension(fileName) {
var ext = fileName.substr(fileName.length - 5, 5);
return ext;
}
/// <reference path="jquery-1.6.2.js" />
/// <reference path="CsvConverter.js" />$(document).ready(function () {
status("ready...");
});function status(msg) {
$("#status").append("<br />\n<span>" + msg + "</span>");
}function doConvert(fileLink, fileName, filePassword) {
status("now converting file..");if (convertCSV(fileLink, fileName, filePassword)) {
status("converting succeeded");
} else {
status("converting failed");
}
}