SpreadsheetGear - performance spreadsheet components
Home | Contact | Site Map | Download | Purchase
Products
SpreadsheetGear 2010
Purchase SpreadsheetGear
Samples
ASP.NET Samples
Windows Forms Samples
Downloads
Licensed Users Downloads
Download 30-Day Evaluation
Support
FAQ
How To
Documentation
Submit Issues
Company
Home Page
About Us
Contact
Resellers
Privacy
News
How To Use SpreadsheetGear 2010

How do I...
1. copy a DataTable or DataSet to an Excel workbook?
2. get a DataSet from a range of values in my workbook?
3. display a range of data in an ASP.NET DataGrid Control?
4. use the calculation engine from a web form?
5. use the spreadsheet control in a Windows Forms Application?
6. disable or replace the WorkbookView control's context menu?
7. consolidate ranges using the IRange.Copy method?
8. define my own custom functions?
9. include a chart in my spreadsheet reports?
10. change the source data range that my chart is linked to?
11. add a picture to my spreadsheet report?
12. use outline levels to group and summarize a range?
13. read a workbook from a stream or write a workbook to a stream?
14. add a hyperlink to my worksheet?
15. add a new worksheet to my workbook?
16. get an IRange from a defined name?
17. refer to an IRange when creating a formula?
18. merge a range of cells?
19. set a border on a range of cells?
20. set the Print Area and Print Titles for a worksheet?
21. set and retrieve cell values as arrays of values?


  
How do I copy a DataTable or DataSet to an Excel workbook?
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.
  
How do I get a DataSet from a range of values in my workbook?
// 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);
  
How do I display a range of data in an ASP.NET DataGrid Control?
See Excel to DataGrid on the DataGrid Samples page.
  
How do I use the calculation engine from a web form?
See the calculation samples on the Calculations Samples page.
  
How do I use the spreadsheet control in a Windows Forms Application?
SpreadsheetGear 2010 comes with the SpreadsheetGear Explorer, a helpful Windows Forms Application sample soluton for Visual Studio 2005 / 2008 / 2010. See Windows Forms Spreadsheet Control Samples for instructions on running the SpreadsheetGear Explorer.
  
How do I disable or replace the WorkbookView control's context menu?
// Disable the context menu
workbookView1.ContextMenuStrip = null;

// Replace the context menu
workbookView1.ContextMenuStrip = myContextMenuStrip;
  
How do I consolidate ranges using the IRange.Copy method?
See Excel Workbook Consolidation on the DataGrid Samples page.
  
How do I define my own custom functions?
See Custom Functions on the Calculations Samples page.
  
How do I include a chart in my spreadsheet reports?
See 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.
  
How do I change the source data range that my chart is linked to?
See the Basic Chart sample 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.
  
How do I add a picture to my spreadsheet report?
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.
  
How do I use outline levels to group and summarize a range?
See Group, Outline and Summarize to Excel on the Excel Reporting Samples page.
  
How do I read a workbook from a stream or write a workbook to a stream?
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);
}
  
How do I add a hyperlink to my worksheet?
// 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.
  
How do I add a new worksheet to my workbook?
// 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";
  
How do I get an IRange from a defined name?
// 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;
  
How do I refer to an IRange when creating a formula?
// 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);
  
How do I merge a range of cells?
// 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();
  
How do I set a border on a range of cells?
// 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;
  
How do I set the Print Area and Print Titles for a worksheet?
// 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";
  
How do I set and retrieve cell values as arrays of values?
// 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;
Like SpreadsheetGear?
SpreadsheetGear 2010
Now Available
NEW!  Autofilters, password protected workbooks, macro-enabled Open XML (.xlsm) support, Excel 2010 support, Visual Studio 2010 and .NET 4.0 support, a number of charting features and more.

Download the FREE Trial.
Microsoft Chooses
SpreadsheetGear for .NET
"After carefully evaluating SpreadsheetGear, Excel Services, and other 3rd party options, we ultimately chose SpreadsheetGear for .NET because it is the best fit for MSN Money."

Chris Donohue
Program Manager
MSN Money
Spreadsheet Component
Industry Veterans
"Our key developers have over fifty years of combined experience developing high performance commercially available spreadsheet technology which is used by most of the Fortune 500."

Joe Erickson
Founder and CEO
SpreadsheetGear LLC
Over 100 Times Faster
Than Other Controls
"We just wanted you to know how thrilled we are by the performance we are seeing with SpreadsheetGear for .NET. A 6,000 KB Excel workbook is loading into the WorkbookView control in less than a second. This is over 100 times faster than other controls we’ve tested. That difference makes it possible for us to develop and release a viable product with the Microsoft .NET Framework."

Amy Tate
Chief .NET Architect
Applied OLAP, Inc.
Huntsville, Alabama
You Have an
Excellent Product
"You have an excellent product. I've finished my testing and was able to rewrite a program using VB.NET and your control. I wrote the previous version 4 years ago using VB6 which employed the Excel COM object. The old program generated about 2100 excel sheets in 8 hours. With your control it now takes 7 minutes!

I also wrote a web form in ASP.NET VB using your control. This was also previously a VB6 / Excel app. This one went from 36 minutes to less than a minute.

I'm having no trouble getting this purchase approved!"

Mark Hitchcock
Manager of Information Technology
Administrative Concepts, Inc.
SpreadsheetGear for .NET
A Pleasure to Work With
"SpreadsheetGear for .NET is truly a pleasure to work with. I was up and running within the first day. It is the best spreadsheet generator out on the market. Performance, Ease of Use, and Full Control of the generation process sold me. I no longer have to be concerned with memory leaks, hung processes, COM Interop and slow performance. Our users demand cosmetically appealing reports without additional work. I can build templates at will, with complete control to freeze panes, page setup, cell formats, etc., etc. The old days of pre-building templates are gone. I cannot think of anything this product cannot do."

Todd Dickard
TA Billing Systems Mgr.
TravelCenters of America
SpreadsheetGear for .NET
Robust & Comprehensive
We really love SpreadsheetGear for .NET. The comprehensive and robust set of worksheet functions ensures that our customers are able to fully leverage their Excel knowledge in our product.

Andreas Lipphardt
XLCubed Ltd
Hessen Germany
SpreadsheetGear Saved
Hours of Development
“SpreadsheetGear helped our team of developers in developing a .NET library that allows users to create custom reports. The ease of use of the SpreadsheetGear product saved us hours of development time and ultimately helped deliver an excellent product to the client. We would definitely recommend using this product!

Robert Jumblatt
Principal
CoreBix LLC
Vienna, VA
SpreadsheetGear - The
Best I Have Encountered
"The sample code you provided has worked very well indeed. Many thanks for your help. As a developer of bespoke software I can honestly say that of all the components my company has ever used, SpreadsheetGear is the best that I have encountered."

Peter Rose, Director
TEKenable, Ltd.
Dublin, Ireland
Best Component Purchase
for Many Years
“SpreadsheetGear for .NET provides a platform for spreadsheet web extension second to none. We were able to implement our custom formulas using the SpreadsheetGear engine with ease and these interact with the Excel functions seamlessly. The performance is superb and in many cases faster than in Excel which has been a pleasant surprise. The expertise of the development team is very apparent and we look forward to the new product enhancements coming down the line. From a return on investment perspective this has been our best component purchase for many years."

Mark Scanlon
Managing Director
XLCubed Ltd
Wow!
Perfect!!!
"Wow! Thank you for the hint!

Your support is like your product: Perfect!!!"

Christian Donges
:em engineering methods AG
Darmstadt, Germany
Above and Beyond Support, Exceptional
"Although there was an initial issue related to date formatting associated with a cultural problem, I found that SpreadsheetGear provided myself, and ultimately the bank, with above and beyond support, providing us with the necessary fix for the issue within 2 days.  This is nothing less than exceptional, and I for one would like to thank SpreadsheetGear for their tenacity, enthusiasm and dedication to their product."

David Lashley
IT Development Manager
Commercial Bank of Qatar
SpreadsheetGear
ROCKS!!!!
"We recently bought SpreadsheetGear for an Excel reporting project and have found it to be excellent!

However, this week I have discovered that I can use SpreadsheetGear to open an Excel spreadsheet and interrogate it on the fly. This facility has literally saved me weeks of work. Hence I am just dropping you a quick email to say thank you very much.

SpreadsheetGear ROCKS!!!!"

Andrew Breward
Caboodal
SpreadsheetGear Kills
The Competition
"I must say that in terms of structure and completeness, SpreadsheetGear kills the competition."

Mark Keogh, Technical Lead
BCC AdSystems
Sydney, Australia
Natural API,
Blindingly Fast, Wow!
“Your interface-based approach is refreshing: the API is natural and the underlying code is blindingly fast for what it does.

Changing my Excel abstraction to use SpreadsheetGear brought a 2 month pull from 48 minutes (2880 seconds) to 12.7 seconds.

Wow!"

Dennis C. Wright
dWare.biz, LLC
Special Product
Great Job
We’ve been using SpreadsheetGear for 5 years. One of the things that makes this product special is that I really don’t have to think about it – I can spend my time worrying about the application that wraps it rather than the technology itself.

The vendor is great to work with too – technical questions are addressed quickly and accurately, without a lot of the refusal to admit problems that plagues other vendors.

Great job!!!

Bill Wilson
Development Manager
Thomson Reuters
Hands Down the Most
Intuitive and Easy to Use
"Thanks again for your prompt response, and I would just like to say that this is by far the best library that I have worked with. It is hands down the most intuitive and easy to use API that I have used to work with Excel files. Its performance is hard to beat as well.”

Levi Wilson
Software Developer
Press Ganey Associates
South Bend, Indiana
Fantastically Powerful
Very Easy To Use
"SpreadsheetGear for .NET is a fantastically powerful spreadsheet component which is very easy to use and expand. We delivered our mandatory customer requirements well before time so we had plenty of time to implement the nice-to-have requirements nobody ever manages to deliver."

Simon Black
Software Architect
Nokia
Reduced Time From
20 Minutes to 4 Seconds
"We integrated SpreadsheetGear for .NET with an existing application with about two days work and it reduced the time it takes to generate a critical daily report from 20 minutes to 4 seconds. Thanks for making my team look like miracle workers!"

Luke Melia, Software
Development Manager
Oxygen Media, New York
Performance, Flexibility
Priceless Support
"We started to use SpreadsheetGear for .NET almost two years ago when the performance of other controls was becoming problematic. We needed a control that could handle large workbooks with complex formulas to be able to apply Monte Carlo simulation to financial statements. Since that time SpreadsheetGear for .NET has become our tool of choice not only for the performance but also for the flexibility. But most of all, the technical support we receive from SpreadsheetGear LLC is priceless; it has always been fast and accurate with the vision to arrive at the desired solution."

Frédérick Faucher
Analyste Financier
Solutions Modex Inc.
Montréal, Canada
ASP.NET and
SpreadsheetGear
A Match Made in Heaven
"ASP.NET and Microsoft Excel is a dangerous combination. ASP.NET and SpreadsheetGear is a match made in heaven. When you need your web or Windows app to interact with Excel files with lightening speed and no COM crashes, SpreadsheetGear for .NET is what you use. This product truly separates the men from the boys in the spreadsheet control marketplace."

Robbe Morris
Microsoft MVP - C#
Co-founder of EggHeadCafe.com and former Gartner Sr. Software Engineer
Copyright © 2003-2011 SpreadsheetGear LLC. All Rights Reserved.
SpreadsheetGear® is a registered trademark and Spreadsheet Gear is a trademark of SpreadsheetGear LLC.
Microsoft, Microsoft Excel, Visual Studio and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.