/// <summary> /// Returns a new reference <see cref="OutputResult"/> that complies with what is indicated in its configuration object. By default, this <see cref="XlsxInput"/> will not be zipped. /// </summary> /// <param name="config">The output result configuration.</param> /// <returns> /// <para> /// A <see cref="OutputResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Result</b> property will contain the Result; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return Result is <see cref="OutputResultData"/>, which contains the operation result /// </para> /// </returns> public OutputResult CreateResult(OutputResultConfig config = null) { OutputResultConfig configToApply = OutputResultConfig.Default; if (config != null) { configToApply = config; configToApply.Filename = NativeIO.Path.ChangeExtension( string.IsNullOrEmpty(config.Filename) ? File.GetUniqueTempRandomFile().Segments.LastOrDefault() : config.Filename, XlsxExtension); } try { if (configToApply.AutoFitColumns) { Set(new SetAutoFitColumns()); } Set(new SetSheetsSettings { Settings = configToApply.GlobalSettings.SheetsSettings }); Set(new SetDocumentSettings { Settings = configToApply.GlobalSettings.DocumentSettings }); if (!configToApply.Zipped) { return(OutputResult.CreateSuccessResult( new OutputResultData { Zipped = false, Configuration = configToApply, UncompressOutputStream = Clone().ToStream() })); } OutputResult zippedOutputResult = OutputResult.CreateSuccessResult(null); // new[] { Clone() }.CreateJoinResult(new[] { configToApply.Filename }); //zippedOutputResult.Result.Configuration = configToApply; return(zippedOutputResult); } catch (Exception e) { return(OutputResult.FromException(e)); } }
/// <summary> /// Returns a new reference <see cref="OutputResult"/> that complies with what is indicated in its configuration object. By default, this <see cref="PdfInput"/> will not be zipped. /// </summary> /// <param name="config">The output result configuration.</param> /// <returns> /// <para> /// A <see cref="OutputResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Result</b> property will contain the Result; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return Result is <see cref="OutputResultData"/>, which contains the operation result /// </para> /// </returns> public OutputResult CreateResult(OutputResultConfig config = null) { OutputResultConfig configToApply = OutputResultConfig.Default; if (config != null) { configToApply = config; configToApply.Filename = NativeIO.Path.ChangeExtension( string.IsNullOrEmpty(config.Filename) ? iTinIO.File.GetUniqueTempRandomFile().Segments.LastOrDefault() : config.Filename, PdfExtension); } try { if (!configToApply.Zipped) { return(OutputResult.CreateSuccessResult( new OutputResultData { Zipped = false, Configuration = configToApply, UncompressOutputStream = Clone().ToStream() })); } OutputResult zippedOutputResult = new[] { Clone() }.CreateJoinResult(new[] { configToApply.Filename }); zippedOutputResult.Result.Configuration = configToApply; return(zippedOutputResult); } catch (Exception e) { return(OutputResult.FromException(e)); } }