private static string GetExportFormatString(ExportFormat f) { switch (f) { case ExportFormat.XML: return("XML"); case ExportFormat.CSV: return("CSV"); case ExportFormat.Image: return("IMAGE"); case ExportFormat.PDF: return("PDF"); case ExportFormat.MHTML: return("MHTML"); case ExportFormat.HTML4: return("HTML4.0"); case ExportFormat.HTML32: return("HTML3.2"); case ExportFormat.Excel: return("EXCEL"); case ExportFormat.Word: return("WORD"); default: return("PDF"); } }
public override string Export(ExportFormat exportFormat) { var ext = "udt"; if (exportFormat == ExportFormat.Xml) { ext = "xml"; } var tmp = Path.GetTempPath(); var file = Path.Combine(tmp, "tmp_dnspt_" + Guid.NewGuid().ToString().Replace("{", "").Replace("}", "").Replace("-", "").Replace(" ", "") + "." + ext); if (ext == "xml") { plcType.Export(new FileInfo(file), Siemens.Engineering.ExportOptions.None); } else { var fld = this.ParentFolder; while (!(fld is TIAOpennessControllerFolder)) { fld = fld.Parent; } ((TIAOpennessControllerFolder)fld).plcSoftware.ExternalSourceGroup.GenerateSource(new[] { this.plcType }, new FileInfo(file), Siemens.Engineering.SW.ExternalSources.GenerateOptions.None); } var text = File.ReadAllText(file); File.Delete(file); return(text); }
// Function : ExportDetails // Arguments : DetailsTable, FormatType, FileName // Purpose : To get all the column headers in the datatable and // exorts in CSV / Excel format with all columns public void ExportDetails(DataTable DetailsTable, ExportFormat FormatType, string FileName) { try { if (DetailsTable.Rows.Count == 0) throw new Exception("There are no details to export."); // Create Dataset DataSet dsExport = new DataSet("Export"); DataTable dtExport = DetailsTable.Copy(); dtExport.TableName = "Values"; dsExport.Tables.Add(dtExport); // Getting Field Names string[] sHeaders = new string[dtExport.Columns.Count]; string[] sFileds = new string[dtExport.Columns.Count]; for (int i = 0; i < dtExport.Columns.Count; i++) { //sHeaders[i] = ReplaceSpclChars(dtExport.Columns[i].ColumnName); sHeaders[i] = dtExport.Columns[i].ColumnName; sFileds[i] = ReplaceSpclChars(dtExport.Columns[i].ColumnName); } if (appType == "Web") Export_with_XSLT_Web(dsExport, sHeaders, sFileds, FormatType, FileName); else if (appType == "Win") Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, FileName); } catch (Exception Ex) { throw Ex; } }
public static Root LoadModel(string inputPath, ExportFormat format) { switch (format) { case ExportFormat.GR2: { using (var fs = new FileStream(inputPath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite)) { var root = new LSLib.Granny.Model.Root(); var gr2 = new LSLib.Granny.GR2.GR2Reader(fs); gr2.Read(root); root.PostLoad(); return root; } } case ExportFormat.DAE: { var root = new LSLib.Granny.Model.Root(); root.ImportFromCollada(inputPath); return root; } default: throw new ArgumentException("Invalid model format"); } }
public override string Export(ExportFormat Format) { if (_error != null && _error != "") { return("Error: " + _error); } if (this.State != StateEnum.Executed) { throw new Exception("Report is not executed"); } if (this._resultData == null) { throw new Exception("Report contains no data"); } if (Format == ExportFormat.HTML) { return(ExportToHTML()); } else if (Format == ExportFormat.CSV) { return(ExportToCSV()); } else { throw new NotSupportedException(); } }
/// <summary> /// Gets the file extension for the given export format. /// </summary> /// <param name="format">The format.</param> /// <returns>The extension.</returns> /// <exception cref="NotImplementedException">Thrown if the format has not been implemented.</exception> public static string GetFileExtension(this ExportFormat format) { switch (format) { case ExportFormat.PDF: { return("pdf"); } case ExportFormat.Plaintext: { return("txt"); } case ExportFormat.JSON: { return("json"); } case ExportFormat.ODT: { return("odt"); } default: { throw new NotImplementedException(); } } }
/// <summary> /// /// </summary> /// <param name="fullPath"></param> /// <param name="cancellationToken"></param> /// <returns></returns> /// <remarks> /// /// </remarks> public override async Task <Stream> OpenReadAsync(string fullPath, CancellationToken cancellationToken = default) { if (fullPath is null) { throw new ArgumentNullException(nameof(fullPath)); } //parse optional format ExportFormat exportFormat = ExportFormat.SOURCE; int hashIdx = fullPath.LastIndexOf("#"); if (hashIdx != -1) { string formatName = fullPath.Substring(hashIdx + 1); fullPath = fullPath.Substring(0, hashIdx); if (Enum.TryParse(formatName, true, out ExportFormat ef)) { exportFormat = ef; } } //notebooks are passed with extensions at the end (.py, .scala etc.) so you need to remove them first string path = Path.ChangeExtension(fullPath, null); // removes extension byte[] notebookBytes = await _api.Export(StoragePath.Normalize(path), exportFormat).ConfigureAwait(false); return(new MemoryStream(notebookBytes)); }
/// <summary> /// Gets the string export format of the specified enum. /// </summary> /// <param name="f">export format enum</param> /// <returns>enum equivalent string export format</returns> public static string GetExportFormatString(ExportFormat f) { int V_SQLServer = SetSQLServerVersion(); switch (f) { case ExportFormat.XML: return "XML"; case ExportFormat.CSV: return "CSV"; case ExportFormat.Image: return "IMAGE"; case ExportFormat.PDF: return "PDF"; case ExportFormat.MHTML: return "MHTML"; case ExportFormat.HTML4: return "HTML4.0"; case ExportFormat.HTML32: return "HTML3.2"; case ExportFormat.Excel: return V_SQLServer <= 2008 ? "EXCEL" : "EXCELOPENXML"; case ExportFormat.Excel_2003: return "EXCEL"; case ExportFormat.Word: return V_SQLServer <= 2008 ? "WORD" : "WORDOPENXML"; case ExportFormat.Word_2003: return "WORD"; default: return "PDF"; } // End switch (f) }
void Export(ExportFormat exportFormat) { Export(exportFormat, (extension) => { return(EditorUtility.SaveFilePanel("Subtexture", Application.dataPath, string.Empty, extension)); }); }
public void Export(object parameter) { RadGridView grid = parameter as RadGridView; if (grid != null) { grid.ElementExporting -= this.ElementExporting; grid.ElementExporting += this.ElementExporting; grid.ElementExported -= this.ElementExported; grid.ElementExported += this.ElementExported; string extension = "xls"; ExportFormat format = ExportFormat.Html; SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = extension; dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"); dialog.FilterIndex = 1; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { GridViewExportOptions options = new GridViewExportOptions(); options.Format = format; options.ShowColumnHeaders = true; options.Encoding = System.Text.Encoding.UTF8; grid.Export(stream, options); } } } }
void Export(ExportFormat format) { PrintableControlLink link = CreateLink(); LinkPreviewModel model = CreateLinkPreviewModel(link); ExportProgressWaitIndicator exportDialog = CreateExportDialog(model); bool buildCompleted = false; EventHandler createDocumentCompletedHandler = (d, e) => { buildCompleted = true; exportDialog.Close(); }; link.PrintingSystem.AfterBuildPages += createDocumentCompletedHandler; link.CreateDocument(true); exportDialog.ShowDialog(); link.PrintingSystem.AfterBuildPages -= createDocumentCompletedHandler; if (buildCompleted) { model.ExportCommand.Execute(format); } else { model.StopCommand.Execute(null); } }
void Export(ExportFormat exportFormat, string filename) { Export(exportFormat, (extension) => { return($"{filename}.{extension}"); }); }
/// <summary> /// Get a header for a series of log records with a delimiter /// </summary> /// <param name="Delimiter"></param> /// <param name="format"></param> /// <returns></returns> private string localHeader(char Delimiter = ',', ExportFormat format = ExportFormat.Full) { string returnValue; StringBuilder localSB = new StringBuilder(); try { localSB.Append("EventDateTime"); localSB.Append(Delimiter + "LogFlag"); localSB.Append(Delimiter + "Message"); localSB.Append(Delimiter + "HostFQDN"); if (format == ExportFormat.Full) { // Use all parameters if we want a full format localSB.Append(Delimiter + "MessageNumber"); localSB.Append(Delimiter + "ProcessID"); localSB.Append(Delimiter + "ThreadID"); localSB.Append(Delimiter + "Component"); localSB.Append(Delimiter + "ProcessName"); localSB.Append(Delimiter + "SessionID"); localSB.Append(Delimiter + "EventFileTime"); } returnValue = localSB.ToString(); } catch (Exception ex) { LogException(ex); returnValue = ""; } return(returnValue); }
/// <summary> /// Return the log record in the form of a Key-Value Pair /// </summary> /// <param name="format">Full or Minimal</param> /// <returns></returns> public string ToKVP(ExportFormat format = ExportFormat.Full) { string returnValue; StringBuilder localSB = new StringBuilder(); try { localSB.AppendFormat("Timestamp=\"{0}\"", this.EventDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); localSB.AppendFormat(", LogFlag=\"{0}\"", this.LogFlag); localSB.AppendFormat(", Message=\"{0}\"", this.Message); localSB.AppendFormat(", HostFQDN=\"{0}\"", this.HostFQDN); if (format == ExportFormat.Full) { // Use all parameters if we want a full format localSB.AppendFormat(", MessageNumber=\"{0}\"", this.MessageNumber); localSB.AppendFormat(", ProcessID=\"{0}\"", this.ProcessID); localSB.AppendFormat(", ThreadID=\"{0}\"", this.ThreadID); localSB.AppendFormat(", Component=\"{0}\"", this.Component); localSB.AppendFormat(", ProcessName=\"{0}\"", this.ProcessName); localSB.AppendFormat(", SessionID=\"{0}\"", this.SessionID); localSB.AppendFormat(", EventFileTime=\"{0}\"", this.EventFileTime); } returnValue = localSB.ToString(); } catch (Exception ex) { LogException(ex); returnValue = ""; } return(returnValue); }
public static void PlotCompound(CompoundData result, string filepath, ExportFormat format = ExportFormat.PNG) { if (format == ExportFormat.NoImageExport) { return; } var plot = CreateCompoundPlot(result, format); switch (format) { case ExportFormat.PDF: SavePlotToPdf(Path.ChangeExtension(filepath, "pdf"), plot); break; case ExportFormat.SVG: SavePlotToSvg(Path.ChangeExtension(filepath, "svg"), plot); break; case ExportFormat.PNG: GuaranteeSingleThreadApartment(() => SavePlotToPng(Path.ChangeExtension(filepath, "png"), plot)); break; case ExportFormat.JPEG: GuaranteeSingleThreadApartment(() => SavePlotToJpg(Path.ChangeExtension(filepath, "jpg"), plot)); break; default: break; } }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportDataWithViews(ExternalCommandData commandData, ExportFormat exportFormat) : base(commandData, exportFormat) { m_selectViewsData = new SelectViewsData(commandData); Initialize(); }
public void Export(Stream stream, ExportFormat format, XlsxExportOptionsEx options = null) { GridControl grid = (GridControl)AssociatedObject; switch (format) { case ExportFormat.Xlsx: { if (options != null) { grid.View.ExportToXlsx(stream, options); } else { grid.View.ExportToXlsx(stream); } break; } case ExportFormat.Pdf: { grid.View.ExportToPdf(stream); break; } case ExportFormat.Csv: { grid.View.ExportToCsv(stream); break; } } }
public void ExportDetails(DataTable DetailsTable, ExportFormat FormatType, string FileName) { try { if (DetailsTable.Rows.Count == 0) { throw new Exception("There are no details to export."); } DataSet dsExport = new DataSet("Export"); DataTable table = DetailsTable.Copy(); table.TableName = "Values"; dsExport.Tables.Add(table); string[] sHeaders = new string[table.Columns.Count]; string[] sFileds = new string[table.Columns.Count]; for (int i = 0; i < table.Columns.Count; i++) { sHeaders[i] = table.Columns[i].ColumnName; sFileds[i] = this.ReplaceSpclChars(table.Columns[i].ColumnName); } if (this.appType == "Web") { this.Export_with_XSLT_Web(dsExport, sHeaders, sFileds, FormatType, FileName); } else if (this.appType == "Win") { this.Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, FileName); } } catch (Exception exception) { throw exception; } }
public static ExportHelper GetHelper(SourceFormat srcFormat, ExportFormat format, Dictionary <string, string> customParams = null) { ExportHelper helper = null; switch (srcFormat) { case SourceFormat.EPUB: helper = new ExportHelperEpub(format); break; case SourceFormat.MHTML: helper = new ExportHelperMhtml(format); break; case SourceFormat.SVG: helper = new ExportHelperSvg(format); break; case SourceFormat.MD: helper = new ExportHelperMarkdown(format); if (customParams != null && customParams.ContainsKey("cssTheme")) { ((ExportHelperMarkdown)helper).CssTheme = customParams["cssTheme"]; } break; case SourceFormat.HTML: case SourceFormat.XHTML: default: helper = new ExportHelperHtml(format); break; } return(helper); }
private async static Task<string> ExportStylesheet(IEnumerable<SpriteFragment> fragments, SpriteDocument sprite, string imageFile, ExportFormat format) { string outputFile = GetFileName(imageFile, sprite, format); var outputDirectory = Path.GetDirectoryName(outputFile); StringBuilder sb = new StringBuilder().AppendLine(GetDescription(format)); string root = ProjectHelpers.GetRootFolder(); foreach (SpriteFragment fragment in fragments) { var rootAbsoluteUrl = FileHelpers.RelativePath(root, fragment.FileName); var bgUrl = sprite.UseAbsoluteUrl ? "/" + FileHelpers.RelativePath(root, imageFile) : FileHelpers.RelativePath(outputFile, imageFile); sb.AppendLine(GetSelector(rootAbsoluteUrl, sprite, format) + " {"); sb.AppendLine("/* You may have to set 'display: block' */"); sb.AppendLine("\twidth: " + fragment.Width + "px;"); sb.AppendLine("\theight: " + fragment.Height + "px;"); sb.AppendLine("\tbackground: url('" + bgUrl + "') -" + fragment.X + "px -" + fragment.Y + "px;"); sb.AppendLine("}"); } bool IsExists = System.IO.Directory.Exists(outputDirectory); if (!IsExists) System.IO.Directory.CreateDirectory(outputDirectory); ProjectHelpers.CheckOutFileFromSourceControl(outputFile); await FileHelpers.WriteAllTextRetry(outputFile, sb.ToString().Replace("-0px", "0")); return outputFile; }
public ExportRequest( Guild guild, Channel channel, string outputPath, ExportFormat format, Snowflake?after, Snowflake?before, int?partitionLimit, bool shouldDownloadMedia, bool shouldReuseMedia, string dateFormat) { Guild = guild; Channel = channel; OutputPath = outputPath; Format = format; After = after; Before = before; PartitionLimit = partitionLimit; ShouldDownloadMedia = shouldDownloadMedia; ShouldReuseMedia = shouldReuseMedia; DateFormat = dateFormat; OutputBaseFilePath = GetOutputBaseFilePath( guild, channel, outputPath, format, after, before ); OutputBaseDirPath = Path.GetDirectoryName(OutputBaseFilePath) ?? OutputPath; OutputMediaDirPath = $"{OutputBaseFilePath}_Files{Path.DirectorySeparatorChar}"; }
public void Export(ExportFormat format, string filePath, ChatLog log) { // Create template loader var loader = new TemplateLoader(); // Get template var templateCode = loader.Load(format); var template = Template.Parse(templateCode); // Create template context var context = new TemplateContext { TemplateLoader = loader, MemberRenamer = m => m.Name, MemberFilter = m => true, LoopLimit = int.MaxValue, StrictVariables = true }; // Create template model var templateModel = new TemplateModel(format, log, _settingsService.DateFormat); context.PushGlobal(templateModel.GetScriptObject()); // Render output using (var output = File.CreateText(filePath)) { // Configure output context.PushOutput(new TextWriterOutput(output)); // Render template template.Render(context); } }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportDWGData(ExternalCommandData commandData, ExportFormat exportFormat) : base(commandData, exportFormat) { m_exportOptionsData = new ExportBaseOptionsData(); Initialize(); }
public TemplateModel(ExportFormat format, ChatLog log, string dateFormat, int messageGroupLimit) { _format = format; _log = log; _dateFormat = dateFormat; _messageGroupLimit = messageGroupLimit; }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService)user.GetService( DfpService.v201403.ReportService); // Set the id of the completed report. long reportJobId = long.Parse(_T("INSERT_REPORT_JOB_ID_HERE")); ExportFormat exportFormat = (ExportFormat)Enum.Parse(typeof(ExportFormat), _T("INSERT_EXPORT_FORMAT_HERE")); // Set the format of the report (e.g., CSV_DUMP) and download without // compression so we can print it. ReportDownloadOptions reportDownloadOptions = new ReportDownloadOptions(); reportDownloadOptions.exportFormat = exportFormat; reportDownloadOptions.useGzipCompression = false; try { // Download report data. string downloadUrl = reportService.getReportDownloadUrlWithOptions(reportJobId, reportDownloadOptions); byte[] rawReport = MediaUtilities.GetAssetDataFromUrl(downloadUrl); string reportContents = Encoding.UTF8.GetString(rawReport); // Display results. Console.WriteLine("Data for report job with id '{0}\':\n{1}", reportJobId, reportContents); } catch (Exception ex) { Console.WriteLine("Failed to download report. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportDXFData(ExternalCommandData commandData, ExportFormat exportFormat) : base(commandData, exportFormat) { m_exportOptionsData = new ExportBaseOptionsData(); Initialize(); }
public async Task <IHttpActionResult> GetMembersExport( string orderBy = "email", Direction orderDirection = Direction.Ascending, string filter = "", ExportFormat format = ExportFormat.Excel) { // Only export if the current user has access to sensitive data. if (!Security.CurrentUser.HasAccessToSensitiveData()) { return(Ok()); } var queryString = Request.GetQueryNameValuePairs(); var memberTypeAlias = GetMemberType(queryString); var filters = GetFilters(queryString); var columns = GetColumns(queryString); var members = MemberSearch.PerformMemberSearch(filter, filters, out _, memberTypeAlias, orderBy: orderBy, orderDirection: orderDirection) .ToExportModel(columns); var name = $"Members - {DateTime.Now:yyyy-MM-dd}"; var filename = $"Members-{DateTime.Now:yyyy-MM-dd}"; var stream = new MemoryStream(); string ext = "csv"; string mimeType = Constants.MimeTypes.CSV; switch (format) { case ExportFormat.CSV: await members.CreateCSVAsync(stream); break; case ExportFormat.Excel: ext = "xlsx"; mimeType = Constants.MimeTypes.Excel; await members.CreateExcelAsync(stream, name); break; } stream.Seek(0, SeekOrigin.Begin); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue(mimeType); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = $"{filename}.{ext}" }; return(ResponseMessage(response)); }
public ExportAllOptions(string token, ExportFormat theme, int year, int month, bool allUpTo) { Token = token; Format = theme; Year = year; Month = month; AllUpTo = allUpTo; }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportCivil3DData(ExternalCommandData commandData, ExportFormat exportFormat) : base(commandData, exportFormat) { m_application = commandData.Application.Application; m_document = commandData.Application.ActiveUIDocument.Document; m_dut = GetLengthUnitType(m_document); Initialize(); }
private void btnCancel_Click(object sender, EventArgs e) { IsOK = false; ExportContent = ExportContent.None; ExportFormat = ExportFormat.None; ExportPath = ""; Close(); }
/// <summary> /// 初始化导出 /// </summary> /// <param name="format">导出格式</param> protected ExportBase(ExportFormat format) { Table = new Table(); _format = format; _headStyle = CellStyle.Head(); _bodyStyle = CellStyle.Body(); _footStyle = CellStyle.Foot(); }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportPDFData(ExternalCommandData commandData, ExportFormat exportFormat) : base(commandData, exportFormat) { m_filter = "PDF Files |*.pdf"; m_title = "Export PDF"; m_combine = true; }
void OnButtonExportAsLASToggle(object sender, ButtonToggleEvent e) { if (e._Active) { _ExportFormat = ExportFormat.LAS; _ButtonExportAsXYZ.SetActive(false); } }
/// <summary> /// Constructor /// </summary> /// <param name="commandData">Revit command data</param> /// <param name="exportFormat">Format to export</param> public ExportData(ExternalCommandData commandData, ExportFormat exportFormat) { m_commandData = commandData; m_activeDoc = commandData.Application.ActiveUIDocument.Document; m_exportFormat = exportFormat; m_filter = String.Empty; Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="PutSlidesConvertRequest"/> class. /// </summary> /// <param name="format">The format.</param> /// <param name="document"></param> /// <param name="password">The document password.</param> /// <param name="outPath">Path to save result</param> /// <param name="fontsFolder">The optional custom fonts folder.</param> public PutSlidesConvertRequest(ExportFormat format, Stream document = null, string password = null, string outPath = null, string fontsFolder = null) { this.Format = format; this.Document = document; this.Password = password; this.OutPath = outPath; this.FontsFolder = fontsFolder; }
public static string Export(IEnumerable<SpriteFragment> fragments, string imageFile, ExportFormat format) { if (format == ExportFormat.Json) { return ExportJson(fragments, imageFile); } return ExportStylesheet(fragments, imageFile, format); }
public async static Task<string> Export(IEnumerable<SpriteFragment> fragments, SpriteDocument sprite, string imageFile, ExportFormat format) { if (format == ExportFormat.Json) { return ExportJson(fragments, sprite, imageFile); } return await ExportStylesheet(fragments, sprite, imageFile, format); }
public static IExporter GetExporter(ExportFormat fmt) { switch (fmt) { case ExportFormat.Txt: return new ExporterTxt(CreateView()); case ExportFormat.Radb: return new ExporterRadb(CreateView()); default: throw new ArgumentException("Specified format is not supported."); } }
private static string GetDescription(ExportFormat format) { string text = "This is an example of how to use the image sprite in your own CSS files"; if (format != ExportFormat.Css) text = "@import this file directly into your existing " + format + " files to use these mixins"; return "/*" + Environment.NewLine + text + Environment.NewLine + "*/"; }
/// <summary> /// 创建导出 /// </summary> /// <param name="format">导出格式</param> public IExport Create( ExportFormat format ) { switch( format ) { case ExportFormat.Xlsx: return CreateNpoiExcel2007Export(); case ExportFormat.Xls: return CreateNpoiExcel2003Export(); } throw new NotImplementedException(); }
public ReportFormatInfo(ExportFormat pFormat) { switch (pFormat) { case ExportFormat.Excel: this.Extension = ".xls"; this.FormatName = "EXCEL"; this.Mime = @"application/vnd.ms-excel"; this.Format = pFormat; break; case ExportFormat.PDF: this.Extension = ".pdf"; this.FormatName = "PDF"; this.Mime = "application/pdf"; this.Format = pFormat; break; case ExportFormat.Html: this.Extension = ".htm"; this.FormatName = "HTML4.0"; this.Mime = "text/html"; this.Format = pFormat; break; case ExportFormat.HtmlFragment: this.Extension = ".htm"; this.FormatName = "HTML4.0"; this.Mime = "text/html"; this.Format = pFormat; // https://msdn.microsoft.com/en-us/library/ms155395.aspx // #oReportCell { width: 100%; } // JavaScript: Indicates whether JavaScript is supported in the rendered report. // The default value is true. // HTMLFragment: Indicates whether an HTML fragment is created in place of a full HTML document. // An HTML fragment includes the report content in a TABLE element and omits the HTML and BODY elements. // The default value is false. // StyleStream: Indicates whether styles and scripts are created as a separate stream instead of in the document. // The default value is false. // StreamRoot: The path used for prefixing the value of the src attribute of the IMG element in the HTML report returned by the report server. // By default, the report server provides the path. // You can use this setting to specify a root path for the images in a report (for example, http://<servername>/resources/companyimages). // <StreamRoot>/ReportServer/Resources</StreamRoot> this.DeviceInfo = @"<DeviceInfo><HTMLFragment>True</HTMLFragment><JavaScript>false</JavaScript><StyleStream>true</StyleStream></DeviceInfo>"; break; case ExportFormat.Image: this.Extension = ".tif"; this.FormatName = "IMAGE"; this.Mime = "image/tiff"; this.Format = ExportFormat.PDF; break; default: this.Extension = ".pdf"; this.FormatName = "PDF"; this.Mime = "application/pdf"; this.Format = ExportFormat.PDF; break; } // End Switch }
public ActionResult _Export(string svg, ExportFormat format) { var svgText = HttpUtility.UrlDecode(svg); var svgFile = TempFileName() + ".svg"; System.IO.File.WriteAllText(svgFile, svgText); var outFile = DoExport(svgFile, format); var attachment = "export" + Path.GetExtension(outFile); return File(outFile, MimeTypes[format], attachment); }
/// <summary> /// 导出SmartGridView的数据源的数据 /// </summary> /// <param name="dt">数据源</param> /// <param name="columnNameList">导出的列的列名数组</param> /// <param name="exportFormat">导出文件的格式</param> /// <param name="fileName">输出文件名</param> /// <param name="encoding">编码</param> public static void Export(DataTable dt, string[] columnNameList, ExportFormat exportFormat, string fileName, Encoding encoding) { List<int> columnIndexList = new List<int>(); DataColumnCollection dcc = dt.Columns; foreach (string s in columnNameList) { columnIndexList.Add(GetColumnIndexByColumnName(dcc, s)); } Export(dt, columnIndexList.ToArray(), exportFormat, fileName, encoding); }
private Root Load(string inPath, ExportFormat format) { switch (format) { case ExportFormat.GR2: return LoadGR2(inPath); case ExportFormat.DAE: return LoadDAE(inPath); default: throw new NotImplementedException("Unsupported input format"); } }
/// <summary>Exports all bookmarks to PDF files.</summary> /// <param name="directory">The directory that the exported files will be written to.</param> /// <param name="dpi">The resolution of the output files.</param> /// <param name="exportFormat">The format of the exported files.</param> public void ExportBookmarksToFiles(string directory, long dpi, ExportFormat exportFormat) { if (!Directory.Exists(directory)) { throw new DirectoryNotFoundException("Directory not found: " + directory); } IMouseCursor mc = new MouseCursorClass(); const int hourglass = 2; mc.SetCursor(hourglass); IMxDocument mxDoc = _app.Document as IMxDocument; IMapBookmarks bookmarks = (IMapBookmarks)mxDoc.FocusMap; IEnumSpatialBookmark enumBM = bookmarks.Bookmarks; enumBM.Reset(); ISpatialBookmark sbm = enumBM.Next(); ProgressDialogFactoryClass dialogFactory = new ProgressDialogFactoryClass(); var cancelTracker = new CancelTrackerClass(); IStepProgressor stepProgressor = dialogFactory.Create(cancelTracker, _app.hWnd); IProgressDialog2 progDialog = stepProgressor as IProgressDialog2; progDialog.CancelEnabled = true; progDialog.ShowDialog(); stepProgressor.Hide(); stepProgressor.Message = "Exporting..."; // Create a formatting string with the proper extension. (E.g., "{0}.pdf" for PDF files".) string fnFmt = string.Format("{{0}}.{0}", Enum.GetName(typeof(ExportFormat), exportFormat)); try { while (sbm != null) { sbm.ZoomTo(mxDoc.FocusMap); string filename = System.IO.Path.Combine(directory, string.Format(fnFmt, sbm.Name)); ExportPageLayoutToFile(mxDoc.PageLayout, filename, dpi, exportFormat); sbm = enumBM.Next(); } } finally { if (progDialog != null) { progDialog.HideDialog(); ComReleaser.ReleaseCOMObject(progDialog); } } }
private void btnOK_Click(object sender, EventArgs e) { if (rbExportNew.Checked) { ExportContent = ExportContent.New; } if (rbExportCommon.Checked) { ExportContent = ExportContent.Common; } if (rbXML.Checked) { ExportFormat = ExportFormat.XML; ExportPath = tbXMLPath.Text; } if (rbText.Checked) { ExportFormat = ExportFormat.Text; ExportPath = tbTextPath.Text; } if (rbCopyFiles.Checked) { ExportFormat = ExportFormat.CopyFile; ExportPath = tbCopyFilePath.Text; } if (rbMoveFiles.Checked) { ExportFormat = ExportFormat.MoveFile; ExportPath = tbMoveFilePath.Text; } if ( ExportContent != ExportContent.None && ExportFormat != ExportFormat.None && !string.IsNullOrEmpty(ExportPath) ) { IsOK = true; Close(); } else { MessageBox.Show("Export options has some matters. Please check and repair options."); } }
public void ExportConversations(ExportFormat exportFormat, string exportPath, IProgressCallback progressCallback) { IConversationExporter conversationExporter; switch (exportFormat) { case ExportFormat.Html: conversationExporter = new ConversationExporterHtml(_exportFileSystem); break; case ExportFormat.Plaintext: conversationExporter = new ConversationExporterPlaintext(_exportFileSystem); break; default: throw new ArgumentException("Unrecognized export format."); } _exportErrors = conversationExporter.ExportMultipleConversations(_conversationManager, _displayOptions, exportPath, progressCallback); }
public void ExportDetails(Janus.Windows.GridEX.GridEX Grilla, ExportFormat FormatType, string FileName) { System.Diagnostics.Process loProcess = System.Diagnostics.Process.GetCurrentProcess(); loProcess.MaxWorkingSet = (IntPtr)10000000; loProcess.MinWorkingSet = (IntPtr)5000000; try { DataSet dsExport = Cedeira.SV.Fun.GetDataSetFromJanusGridEx(Grilla, FileName); dsExport.DataSetName = "Export"; dsExport.Tables[0].TableName = "Values"; string[] sHeaders = new string[dsExport.Tables[0].Columns.Count]; string[] sFileds = new string[dsExport.Tables[0].Columns.Count]; for (int i = 0; i < dsExport.Tables[0].Columns.Count; i++) { dsExport.Tables[0].Columns[i].ColumnName = Convert.ToString(i); } for (int i = 0; i < dsExport.Tables[0].Columns.Count; i++) { sHeaders[i] = ReemplazarEspaciosyAcentos(dsExport.Tables[0].Columns[i].Caption); dsExport.Tables[0].Columns[i].ColumnName = sHeaders[i]; sFileds[i] = sHeaders[i]; } for (int l = 0; l < dsExport.Tables[0].Rows.Count; l++) { for (int i = 0; i < dsExport.Tables[0].Columns.Count; i++) { string aux = ReemplazarXPath(Convert.ToString(dsExport.Tables[0].Rows[l].ItemArray[i])); dsExport.Tables[0].Rows[l][i] = aux; dsExport.Tables[0].Rows[l].AcceptChanges(); } } string dir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "\\CedForecast\\"; if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } FileName = dir + ReemplazarCaracteresMalos(FileName); Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, FileName); System.Diagnostics.Process.Start(FileName); } catch (Exception Ex) { throw Ex; } }
/// <summary> /// 导出SmartGridView的数据源的数据 /// </summary> /// <param name="dt">数据源</param> /// <param name="columnIndexList">导出的列索引数组</param> /// <param name="exportFormat">导出文件的格式</param> /// <param name="fileName">输出文件名</param> /// <param name="encoding">编码</param> public static void Export(DataTable dt, int[] columnIndexList, ExportFormat exportFormat, string fileName, Encoding encoding) { DataSet dsExport = new DataSet("Export"); DataTable dtExport = dt.Copy(); dtExport.TableName = "Values"; dsExport.Tables.Add(dtExport); string[] headers = new string[columnIndexList.Length]; string[] fields = new string[columnIndexList.Length]; for (int i = 0; i < columnIndexList.Length; i++) { headers[i] = dtExport.Columns[columnIndexList[i]].ColumnName; fields[i] = ReplaceSpecialChars(dtExport.Columns[columnIndexList[i]].ColumnName); } Export(dsExport, headers, fields, exportFormat, fileName, encoding, null); }
private string DoExport(string svgFile, ExportFormat format) { var extension = format == ExportFormat.PNG ? "png" : "pdf"; var outFile = TempFileName() + "." + extension; // Full list of export options is available at // http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Export.html var inkscape = new Process(); inkscape.StartInfo.FileName = INKSCAPE_PATH; inkscape.StartInfo.Arguments = String.Format("--file \"{0}\" --export-{1} \"{2}\" --export-width {3} --export-height {4}", svgFile, extension, outFile, WIDTH, HEIGHT); inkscape.StartInfo.UseShellExecute = true; inkscape.Start(); inkscape.WaitForExit(); return outFile; }
/// <summary> /// 导出SmartGridView的数据源的数据 /// </summary> /// <param name="dt">数据源</param> /// <param name="exportFormat">导出文件的格式</param> /// <param name="fileName">输出文件名</param> /// <param name="encoding">编码</param> public static void Export(DataTable dt, ExportFormat exportFormat, string fileName, Encoding encoding) { DataSet dsExport = new DataSet("Export"); DataTable dtExport = dt.Copy(); dtExport.TableName = "Values"; dsExport.Tables.Add(dtExport); string[] headers = new string[dtExport.Columns.Count]; string[] fields = new string[dtExport.Columns.Count]; for (int i = 0; i < dtExport.Columns.Count; i++) { headers[i] = dtExport.Columns[i].ColumnName; fields[i] = ReplaceSpecialChars(dtExport.Columns[i].ColumnName); } Export(dsExport, headers, fields, exportFormat, fileName, encoding); }
private static string ExportStylesheet(IEnumerable<SpriteFragment> fragments, string imageFile, ExportFormat format) { StringBuilder sb = new StringBuilder(); sb.AppendLine(GetDescription(format)); foreach (SpriteFragment fragment in fragments) { sb.AppendLine(GetSelector(fragment.FileName, format) + " {"); sb.AppendLine("/* You may have to set 'display: block' */"); sb.AppendLine("\twidth: " + fragment.Width + "px;"); sb.AppendLine("\theight: " + fragment.Height + "px;"); sb.AppendLine("\tbackground: url('" + Path.GetFileName(imageFile) + "') -" + fragment.X + "px -" + fragment.Y + "px;"); sb.AppendLine("}"); } string outputFile = GetFileName(imageFile, format); ProjectHelpers.CheckOutFileFromSourceControl(outputFile); File.WriteAllText(outputFile, sb.ToString().Replace("-0px", "0"), Encoding.UTF8); return outputFile; }
// Function : Export_with_XSLT_Windows // Arguments : dsExport, sHeaders, sFileds, FormatType, FileName // Purpose : Exports dataset into CSV / Excel format private void Export_with_XSLT_Windows(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName) { try { // XSLT to use for transforming this dataset. MemoryStream stream = new MemoryStream( ); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); CreateStylesheet(writer, sHeaders, sFileds, FormatType); writer.Flush( ); stream.Seek( 0, SeekOrigin.Begin); XmlDataDocument xmlDoc = new XmlDataDocument(dsExport); XslTransform xslTran = new XslTransform(); xslTran.Load(new XmlTextReader(stream), null, null); System.IO.StringWriter sw = new System.IO.StringWriter(); xslTran.Transform(xmlDoc, null, sw, null); //Writeout the Content StreamWriter strwriter = new StreamWriter(FileName); strwriter.WriteLine(sw.ToString()); strwriter.Close(); sw.Close(); writer.Close(); stream.Close(); } catch(Exception Ex) { throw Ex; } }
// Function : Export_with_XSLT_Web // Arguments : dsExport, sHeaders, sFileds, FormatType, FileName // Purpose : Exports dataset into CSV / Excel format private void Export_with_XSLT_Web(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName) { try { // Appending Headers response.Clear(); response.Buffer= true; if(FormatType == ExportFormat.CSV) { response.ContentType = "text/csv"; response.AppendHeader("content-disposition", "attachment; filename=" + FileName); } else { response.ContentType = "application/vnd.ms-excel"; response.AppendHeader("content-disposition", "attachment; filename=" + FileName); } //response.BinaryWrite(Encoding.Unicode.GetPreamble()); // XSLT to use for transforming this dataset. MemoryStream stream = new MemoryStream( ); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); CreateStylesheet(writer, sHeaders, sFileds, FormatType); writer.Flush( ); stream.Seek( 0, SeekOrigin.Begin); XmlDataDocument xmlDoc = new XmlDataDocument(dsExport); //dsExport.WriteXml("Data.xml"); XslTransform xslTran = new XslTransform(); xslTran.Load(new XmlTextReader(stream), null, null); System.IO.StringWriter sw = new System.IO.StringWriter(); xslTran.Transform(xmlDoc, null, sw, null); //xslTran.Transform(System.Web.HttpContext.Current.Server.MapPath("Data.xml"), null, sw, null); //Writeout the Content response.Write(sw.ToString()); sw.Close(); writer.Close(); stream.Close(); response.End(); } catch(ThreadAbortException Ex) { string ErrMsg = Ex.Message; } catch(Exception Ex) { throw Ex; } }
// Function : WriteStylesheet // Arguments : writer, sHeaders, sFileds, FormatType // Purpose : Creates XSLT file to apply on dataset's XML file private void CreateStylesheet(XmlTextWriter writer, string[] sHeaders, string[] sFileds, ExportFormat FormatType) { try { // xsl:stylesheet string ns = "http://www.w3.org/1999/XSL/Transform"; writer.Formatting = Formatting.Indented; writer.WriteStartDocument( ); writer.WriteStartElement("xsl","stylesheet",ns); writer.WriteAttributeString("version","1.0"); writer.WriteStartElement("xsl:output"); writer.WriteAttributeString("method","text"); writer.WriteAttributeString("version","4.0"); writer.WriteEndElement( ); // xsl-template writer.WriteStartElement("xsl:template"); writer.WriteAttributeString("match","/"); // xsl:value-of for headers for(int i=0; i< sHeaders.Length; i++) { writer.WriteString("\""); writer.WriteStartElement("xsl:value-of"); writer.WriteAttributeString("select", "'" + sHeaders[i] + "'"); writer.WriteEndElement( ); // xsl:value-of writer.WriteString("\""); if (i != sFileds.Length - 1) writer.WriteString( (FormatType == ExportFormat.CSV ) ? "," : " " ); } // xsl:for-each writer.WriteStartElement("xsl:for-each"); writer.WriteAttributeString("select","Export/Values"); writer.WriteString("\r\n"); // xsl:value-of for data fields for(int i=0; i< sFileds.Length; i++) { writer.WriteString("\""); writer.WriteStartElement("xsl:value-of"); writer.WriteAttributeString("select", sFileds[i]); writer.WriteEndElement( ); // xsl:value-of writer.WriteString("\""); if (i != sFileds.Length - 1) writer.WriteString( (FormatType == ExportFormat.CSV ) ? "," : " " ); } writer.WriteEndElement( ); // xsl:for-each writer.WriteEndElement( ); // xsl-template writer.WriteEndElement( ); // xsl:stylesheet writer.WriteEndDocument( ); } catch(Exception Ex) { throw Ex; } }
// Function : ExportDetails // Arguments : DetailsTable, ColumnList, Headers, FormatType, FileName // Purpose : To get the specified column headers in the datatable and // exorts in CSV / Excel format with specified columns and // with specified headers public void ExportDetails(DataTable DetailsTable, int[] ColumnList, string[] Headers, ExportFormat FormatType, string FileName) { try { if(DetailsTable.Rows.Count == 0) throw new Exception("There are no details to export"); // Create Dataset DataSet dsExport = new DataSet("Export"); DataTable dtExport = DetailsTable.Copy(); dtExport.TableName = "Values"; dsExport.Tables.Add(dtExport); if(ColumnList.Length != Headers.Length) throw new Exception("ExportColumn List and Headers List should be of same length"); else if(ColumnList.Length > dtExport.Columns.Count || Headers.Length > dtExport.Columns.Count) throw new Exception("ExportColumn List should not exceed Total Columns"); // Getting Field Names string[] sFileds = new string[ColumnList.Length]; for (int i=0; i < ColumnList.Length; i++) { if((ColumnList[i] < 0) || (ColumnList[i] >= dtExport.Columns.Count)) throw new Exception("ExportColumn Number should not exceed Total Columns Range"); sFileds[i] = ReplaceSpclChars(dtExport.Columns[ColumnList[i]].ColumnName); } if(appType == "Web") Export_with_XSLT_Web(dsExport, Headers, sFileds, FormatType, FileName); else if(appType == "Win") Export_with_XSLT_Windows(dsExport, Headers, sFileds, FormatType, FileName); } catch(Exception Ex) { throw Ex; } }
private FieldExportFormat(string format, ExportFormat? exportFormat) { if (exportFormat.HasValue) { ExportFormat = exportFormat; } else { Format = format; } }
public FieldExportFormat(ExportFormat exportFormat) { ExportFormat = exportFormat; }