Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/Data/CodeExamples/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/Data/CodeExamples/ImportExportActions.cs

using System;
using System.IO;
using DevExpress.Spreadsheet;

namespace SpreadsheetExamples {
    public static class ImportExportActions {
        static void ImportArrays(IWorkbook workbook) {
            #region #ImportArrays
            Worksheet worksheet = workbook.Worksheets[0];
            // Create an array containing string values.
            string[] array = new string[] { "AAA", "BBB", "CCC", "DDD" };

            // Import an array to the third row and second column horizontally.
            worksheet.Import(array, 2, 1, false);

            // Create a two-dimensional array containing string values.
            String[,] names = new String[2, 4]{
            {"Ann", "Edward", "Angela", "Alex"},
            {"Rachel", "Bruce", "Barbara", "George"}
                 };
            // Import a two-dimensional array to the fifth row and third column.
            worksheet.Import(names, 5, 2);
            #endregion #ImportArrays
        }

        static void ExportToPdf(IWorkbook workbook) {
            #region #ExportToPdf
            Worksheet firstSheet = workbook.Worksheets[0];
            firstSheet.Cells["B2"].Value = "This document is exported to the PDF format";
            Table table = firstSheet.Tables.Add(firstSheet["A1:H30"], false);
            table.Style = workbook.TableStyles[BuiltInTableStyleId.TableStyleMedium14];
            table.ShowTotals = true;
            table.Columns[0].TotalsRowLabel = "Total";
            
            using (FileStream pdfFileStream = new FileStream("Document_PDF.pdf", FileMode.Create)) {
                workbook.ExportToPdf(pdfFileStream);
            }
            System.Diagnostics.Process.Start("Document_PDF.pdf");
            #endregion #ExportToPdf
        }

    }
}