This demo uses the DevExpress Presentation API to add tables to presentation slides.
Specify the number of rows and columns, column width, and style settings for the table. Use the Generate and Save as... dropdown button to select the output format, generate a presentation with a table, and download the result.
using DevExpress.Docs.Presentation;
using DevExpress.Office.Utils;
Stream CreatePresentationTable(int rows, int columns, float columnWidthInInches, TableStyleType styleType,
bool hasHeader, bool hasBandedRows, bool hasBandedColumns, bool isPdfOutput, DocumentFormat format) {
using var presentation = new Presentation();
presentation.Slides.Clear();
var slide = new Slide(SlideLayoutType.Blank);
presentation.Slides.Add(slide);
var tableWidth = Units.InchesToDocumentsF(columns * columnWidthInInches);
var table = new Table(rows, columns, 100, 100, tableWidth) {
Style = new ThemedTableStyle(styleType),
HasHeaderRow = hasHeader,
HasBandedRows = hasBandedRows,
HasBandedColumns = hasBandedColumns
};
slide.Shapes.Add(table);
var outputStream = new MemoryStream();
if(isPdfOutput)
presentation.ExportToPdf(outputStream);
else
presentation.SaveDocument(outputStream, format);
outputStream.Position = 0;
return outputStream;
}