| |
See DataTable to Excel Workbook or DataSet to Excel Workbook with Formats and Formulas on the Excel Reporting Samples page.
Note: Excel or an Excel compatible spreadsheet application must be installed on the client in order for the spreadsheet to display. |
| |
// Create a workbook from an Excel file IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook("myfile.xls"); // Get a DataSet from an existing defined name DataSet dataSet = workbook.GetDataSet("mydefinedname", SpreadsheetGear.Data.GetDataFlags.FormattedText); |
| |
| See Excel to DataGrid on the DataGrid Samples page. |
| |
See Excel Report in Browser on the Excel Reporting Samples page.
Note: Excel or an Excel compatible spreadsheet application must be installed on the client in order for the spreadsheet to display. |
| |
| See the calculation samples on the Calculations Samples page. |
| |
| SpreadsheetGear for .NET 2007 comes with the SpreadsheetGear Explorer, a helpful Windows Forms Application sample soluton for Visual Studio 2005 and Visual Studio 2008. See Windows Forms Spreadsheet Control Samples for instructions on running the SpreadsheetGear Explorer. |
| |
// Disable the context menu workbookView1.ContextMenuStrip = null;
// Replace the context menu workbookView1.ContextMenuStrip = myContextMenuStrip; |
| |
| See Excel Workbook Consolidation on the DataGrid Samples page. |
| |
| See Custom Functions on the Calculations Samples page. |
| |
See Excel Report with Chart or DataTable to Excel Workbook with Chart on the Excel Charting Samples page.
Note: Excel or an Excel compatible spreadsheet application must be installed on the client in order for the spreadsheet to display. |
| |
See Excel Report with Chart Linked to Defined Name on the Excel Charting Samples page.
Note: Excel or an Excel compatible spreadsheet application must be installed on the client in order for the spreadsheet to display. |
| |
See Excel Report with Picture on the Excel Reporting Samples page.
Note: Excel or an Excel compatible spreadsheet application must be installed on the client in order for the spreadsheet to display. |
| |
| See Group, Outline and Summarize to Excel on the Excel Reporting Samples page. |
| |
public static IWorkbook OpenWorkbook(System.IO.Stream stream) { // Read a workbook from a stream and return it. return SpreadsheetGear.Factory.GetWorkbookSet() .Workbooks.OpenFromStream(stream); }
public static void SaveWorkbook(System.IO.Stream stream) { // Create a workbook and write it to the stream. IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); workbook.SaveToStream( stream, SpreadsheetGear.FileFormat.XLS97); } |
| |
// Create a workbook and get the first worksheet. IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"];
// Add a hyperlink to cell A1. worksheet.Hyperlinks.Add(worksheet.Cells["A1"], @"http://www.spreadsheetgear.com", null, "My Screen Tip", "My Hyperlink Text");
Note: Hyperlinks can be linked to web pages, email addresses, workbook files and references to ranges in the current workbook. Hyperlinks can also be created by using the HYPERLINK function. |
| |
// Create a workbook. IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); // Get the first default worksheet, name it and add a formula. IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Name = "MyFirstSheet"; worksheet.Cells["A1"].Value = 123.456; // Add a new 2nd worksheet, name it and add a formula. worksheet = workbook.Worksheets.Add(); worksheet.Name = "MySecondSheet"; worksheet.Cells["A1"].Formula = "=MyFirstSheet!A1 * 2"; |
| |
// Create a workbook. IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
// Get the first worksheet and name it IWorksheet mySheet = workbook.Worksheets[0]; mySheet.Name = "MySheet";
// Create a defined name which references A1. INames names = workbook.Names; names.Add("MyName", "=MySheet!$A$1");
// Get the IRange for the defined name. IRange cell = names["MyName"].RefersToRange; |
| |
// Create a workbook and get the first worksheet IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"];
// Get an IRange and set up random values IRange rangeValues = worksheet.Range["A1:A10"]; rangeValues.Formula = "=RAND() * 10000";
// Get an IRange and add a formula to sum the values IRange rangeFormula = worksheet.Range["A11"]; rangeFormula.Formula = "=SUM(" + rangeValues.Address + ")";
// Output the calculated value System.Console.WriteLine("Sum = " + rangeFormula.Text); |
| |
// Create a workbook and get the first worksheet IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"];
// Merge a range of cells worksheet.Cells["A1:D2"].Merge(); |
| |
// Create a workbook and get the first worksheet IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"]; // Set the bottom border of a range of cells IRange range = worksheet.Cells["A1:D1"]; IBorder border = range.Borders[SpreadsheetGear.BordersIndex.EdgeBottom]; border.LineStyle = SpreadsheetGear.LineStyle.Continous; border.Color = System.Drawing.Color.Blue; border.Weight = SpreadsheetGear.BorderWeight.Thick; |
| |
// Create a workbook and get the first worksheet PageSetup IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"]; IPageSetup pageSetup = worksheet.PageSetup;
// Set the Print Area pageSetup.PrintArea = "Sheet1!$B$2:$F$20";
// Set the Print Titles pageSetup.PrintTitleRows = "Sheet1!$1:$1"; pageSetup.PrintTitleColumns = "Sheet1!$A:$A"; |
| |
// Create a workbook and get the first worksheet IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"];
// Create a 10 row by 2 column array of values object[,] values = new object[10, 2]; for (int i = 0; i < 10; i++) { values[i, 0] = "Row=" + i + " Col=0"; values[i, 1] = "Row=" + i + " Col=1"; }
// Set the values in the worksheet // Notice the range "A1:B10" has to match the size of the array worksheet.Cells["A1:B10"].Value = values;
// Get the values from the worksheet object[,] retVals = (object[,])worksheet.Cells["A1:B10"].Value;
|
|