public static int Handle(SpreadsheetExportParameters options) { try { var collectionSettings = GetCollectionSettings(options.BookPath); var exporter = new SpreadsheetExporter(null, collectionSettings); if (!string.IsNullOrEmpty(options.ParamsPath)) { exporter.Params = SpreadsheetExportParams.FromFile(options.ParamsPath); } var dom = new HtmlDom(XmlHtmlConverter.GetXmlDomFromHtmlFile(options.BookPath, false)); string imagesFolderPath = Path.GetDirectoryName(options.BookPath); // It's too dangerous to use the output path they gave us, since we're going to wipe out any existing // content of the directory we pass to ExportToFolder. If they give us a parent folder by mistake, that // could be something huge, like "my documents". So assume it IS a parent folder, and make one within it. string outputFolderPath = Path.Combine(options.OutputPath, Path.GetFileNameWithoutExtension(imagesFolderPath)); var _sheet = exporter.ExportToFolder(dom, imagesFolderPath, outputFolderPath, out string unused, null, options.Overwrite ? OverwriteOptions.Overwrite: OverwriteOptions.Quit); return(0); // all went well } catch (Exception ex) { Debug.WriteLine(ex.Message); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return(1); } }
public static int Handle(SpreadsheetExportParameters options) { try { var dom = new HtmlDom(XmlHtmlConverter.GetXmlDomFromHtmlFile(options.BookPath, false)); var exporter = new SpreadsheetExporter(); if (!string.IsNullOrEmpty(options.ParamsPath)) { exporter.Params = SpreadsheetExportParams.FromFile(options.ParamsPath); } var _sheet = exporter.Export(dom); _sheet.WriteToFile(options.OutputPath); return(0); // all went well } catch (Exception ex) { Debug.WriteLine(ex.Message); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return(1); } }