Beispiel #1
0
        public void RemoveSheet()
        {
            SpreadsheetDocument document = SpreadSheetExtensions.ExcelDocument();

            document.RemoveSheet(@"Report");
            SheetData sheet = document.GetSheetData(@"Report");

            Assert.True(sheet.IsNotValid());
        }
Beispiel #2
0
        /// <summary>
        /// Converts a paginated collection of entities into
        /// a spreadsheet document
        /// </summary>
        /// <typeparam name="T">Entity Type</typeparam>
        /// <param name="page">Page reference</param>
        /// <returns>SpreadsheetDocument</returns>
        public static async Task <SpreadsheetDocument> ToExcelDocument <T>(this PaginatedCollection <T> page) where T : class, IEntity, new()
        {
            //Verify page collection
            if (page == null || page.Collection.IsNotValid() || page.Pagination == null)
            {
                return(null);
            }
            SpreadsheetDocument document = SpreadSheetExtensions.ExcelDocument();

            //Remove previous template sheets
            document.RemoveSheet(@"Report");
            document.RemoveSheet(@"Entity");
            document.AddSheet(@"Report");
            //Add a new sheet
            SheetData sheet = document.GetSheetData(@"Report");
            //Add the sheet data
            await sheet.AddRows(page.Collection.AsArray());

            return(document);
        }