excel2pdf(新人请多多指教)
import win.ui;/*DSG{{*/
mainForm = win.form(text="一键转PDF";right=499;bottom=299;max=false)
mainForm.add(
btnChoice={cls="button";text="…";left=312;top=24;right=362;bottom=74;font=LOGFONT(h=-22);z=1};
btnExcel2Pdf={cls="button";text="一键转PDF";left=312;top=120;right=392;bottom=170;z=3};
staticDir={cls="static";text="请选择要转PDF的Excel文件";left=8;top=24;right=308;bottom=74;bgcolor=16777215;border=1;center=1;color=255;z=2}
)
/*}}*/
Excel2Pdf=function(path,...){
import com.excel;
var excel,err = com.excel();
assert(excel,err);
excel.alerts = false;//关闭所有操作提示
var book = excel.Open(path);
pdfName = string.split(path,'.')[]+".pdf"
book.ExportAsFixedFormat(0 /*xlTypePDF*/,pdfName);
book.close();
excel.Quit();
}
mainForm.btnChoice.oncommand = function(id,event){
import fsys.dlg;
path = fsys.dlg.open("Excel文件|*.xls;*.xlsx","请选择Excel文件",,mainForm);
mainForm.staticDir.text = path;
}
mainForm.btnExcel2Pdf.oncommand = function(id,event){
Excel2Pdf(path);
}
mainForm.show();
win.loopMessage();
页:
[1]