Exemple #1
0
        static void Main(string[] args)
        {
            var filename = "./Teste.xlsx";

            // for (uint i = 1; i < 100; i++)
            // {
            //     Console.Write(Util.GetCharColumn(i) + ",");
            // }

            // Console.WriteLine(Util.GetCharColumn(26* 26 +5) + ",");//ZE
            // Console.WriteLine(Util.GetCharColumn(26* 26 + (26) +5) + ",");//AAE
            // Console.WriteLine(Util.GetCharColumn(26* 26 + (26 * 26) +5) + ",");//AZE
            // Console.WriteLine(Util.GetCharColumn(26* 26 + (26 * 26) + 26 + 1) + ",");//BAA


            ExcelBuilder.Builder()
            .WithPath(filename)
            .WithOverrideFile()
            .WithSheet(SheetBuilder.Builder()
                       .WithName("Turtles Sheet")
                       .Build()
                       )
            .WithSheet(SheetBuilder.Builder()
                       .WithName("Rafael")
                       .WithNewLine()
                       .WithColumnValue("teste")
                       .WithColumnValue(123)
                       .Build()
                       )
            .Build();
            // if(File.Exists(filename)){
            //     File.Delete(filename);
            // }
            // Create a spreadsheet document by supplying the filepath.
            // By default, AutoSave = true, Editable = true, and Type = xlsx.
            // SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
            //     Create(filename, SpreadsheetDocumentType.Workbook);

            // // Add a WorkbookPart to the document.
            // WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
            // workbookpart.Workbook = new Workbook();

            // // Add a WorksheetPart to the WorkbookPart.
            // WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
            // worksheetPart.Worksheet = new Worksheet(new SheetData());

            // // Add Sheets to the Workbook.
            // Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
            //     AppendChild<Sheets>(new Sheets());

            // // Append a new worksheet and associate it with the workbook.
            // Sheet sheet = new Sheet() { Id = spreadsheetDocument.WorkbookPart.
            //     GetIdOfPart(worksheetPart), SheetId = 1, Name = "Sheet abc" };
            // var sheetData = new SheetData();
            // var sheetData1 = new SheetData();


            // var row = new Row() { RowIndex = 1 };
            // var cell = new Cell() {CellReference = "A1",
            //      CellValue = new CellValue("Rafael Santos"),
            //      DataType  = new EnumValue<CellValues>(CellValues.String)
            // };
            // row.Append(cell);
            // sheetData.Append(row);

            // worksheetPart.Worksheet.Append(sheetData);

            // sheets.Append(sheet);


            // WorksheetPart worksheetPart1 = workbookpart.AddNewPart<WorksheetPart>();
            // worksheetPart1.Worksheet = new Worksheet(new SheetData());

            // var row1 = new Row() { RowIndex = 1 };
            // var cell1 = new Cell() {CellReference = "A1",
            //      CellValue = new CellValue("BlablaBla Santos"),
            //      DataType  = new EnumValue<CellValues>(CellValues.String)
            // };
            // row1.Append(cell1);
            // sheetData1.Append(row1);

            // worksheetPart1.Worksheet.Append(sheetData1);

            // sheets.Append(new Sheet() { Id = spreadsheetDocument.WorkbookPart.
            //     GetIdOfPart(worksheetPart1), SheetId = 2, Name = "Sheet 2" });

            // workbookpart.Workbook.Save();

            // // Close the document.
            // spreadsheetDocument.Close();

            Console.WriteLine("Hello World!");
        }