Exemplo n.º 1
0
        /// <summary>
        /// Contains data relating to the file-transfer aspects of the report. This overload is used when there is no template file being used, and no backup directory is provided.
        /// </summary>
        /// <param name="name">The FileName to use when saving the report.</param>
        /// <param name="data">List of sheets to create the report.</param>
        /// <param name="method">The optional save method: Local or Download.</param>
        public XlFileInfo(string name, IEnumerable <XlSheet> data, XlSaveMethod method = XlSaveMethod.Local)
        {
            FileName = name;

            if (method == XlSaveMethod.Download)
            {
                Output = new XlDownload();
            }
            else
            {
                Output = new XlDownloadAndBackup();
            }

            FileSource = new XlBlankSource(data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Contains data relating to the file-transfer aspects of the report. This overload is used when there is no template file being used, and providing a backup diretcory.
        /// </summary>
        /// <param name="name">The FileName to use when saving ethe report.</param>
        /// <param name="directory">How to locate the save directory. This may be an AppSettings key, a virtual path, or the absolute path to the directory.</param>
        /// <param name="data">List of sheets to create the report.</param>
        public XlFileInfo(string name, string directory, IEnumerable <XlSheet> data)
        {
            FileName   = name;
            Output     = new XlDownloadAndBackup();
            FileSource = new XlBlankSource(data);

            BackupPath = Utils.GetDirPathIfExists(directory, out bool exists);

            if (!exists)
            {
                throw new DirectoryNotFoundException(
                          $"No backup directory could be found using '{directory}' checking in AppSettings, " +
                          "Virtual Paths, and Absolute Paths. Please provide a valid key for AppSettings, " +
                          "a valid Virtual Path, or a valid Absolute Path.");
            }
        }