using( var doc = Workbook.Load( "test.xlsx") ) // Loads an existing Workbook named “test.xlsx”. { var worksheet = doc.Worksheets[ 1 ]; // Gets the second worksheet. worksheet.Cells[ “A2” ].Value = 12; // Sets a value in “A2”. var stream = new MemoryStream(); doc.SaveAs( stream); // Saves the result in a stream. } var stream = new MemoryStream(); using( var doc = Workbook.Create( stream ) ) // Creates a workbook in a stream. { var worksheet = doc.Worksheets[ 1 ]; // Gets the second worksheet. worksheet.Cells[ “A2” ].Value = 12; // Sets a value in “A2”. worksheet.Columns[ 1 ].Cells[ 0 ].Formula = “=SUM(A1:A2)”; //Sets a formula in “B1”. doc.CalculateFormulas(); // Calculate the Value of “B1”, which contains a formula and for all other Worksheets containing cells with formulas. doc.Save(); // Saves the Workbook in the stream. }
System.Object
Xceed.Workbooks.NET.Workbook
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2