|
@@ -275,23 +275,9 @@ class KMConvertPDFManager: NSObject {
|
|
|
|
|
|
class func convertExcelPath(_ filePath: String, savePath: String, completionHandler: @escaping ((Bool, NSDictionary?) -> Void)) {
|
|
|
DispatchQueue.global().async {
|
|
|
- var convertString = String(format: "set filePath to\"%@\"\n", filePath)
|
|
|
- convertString = convertString.appendingFormat("set savePath to \"%@\"\n", savePath)
|
|
|
- convertString.append("set tFile to (POSIX path of filePath) as POSIX file\n")
|
|
|
- convertString.append("tell application \"Microsoft Excel\"\n")
|
|
|
- convertString.append("set isRun to running\n")
|
|
|
- convertString.append("set wkbk1 to open workbook workbook file name tFile\n")
|
|
|
- convertString.append("alias savePath\n")
|
|
|
- convertString.append("save workbook as wkbk1 filename savePath file format PDF file format with overwrite\n")
|
|
|
- convertString.append("close wkbk1 saving no\n")
|
|
|
- convertString.append("if not isRun then quit\n")
|
|
|
- convertString.append("end tell\n")
|
|
|
-
|
|
|
- let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
- let docScript = NSAppleScript(source: convertString)
|
|
|
- docScript?.executeAndReturnError(dic)
|
|
|
+ let dic = KMOCTool.convertExcel(toPdfFilePath: filePath, savePath: savePath)
|
|
|
DispatchQueue.main.async {
|
|
|
- completionHandler(true, dic?.pointee)
|
|
|
+ completionHandler(true, dic as NSDictionary)
|
|
|
}
|
|
|
}
|
|
|
}
|