Xceed Workbooks for .NET: The Ultimate Excel .Net Library
Excel is a popular tool for working with data, but its functionality can be limited when it comes to large data sets and complex calculations. This is where Xceed Workbooks for .NET comes in. Xceed Workbooks is a powerful Excel .NET library that provides developers with a wide range of features for manipulating data in Excel workbooks.
What is Xceed Workbooks for .NET ?
Xceed Workbooks for .NET is a .NET library that provides a comprehensive set of features for working with Excel files in .NET applications. With Xceed Workbooks, you can read, write, and modify Excel files programmatically, without requiring Microsoft Excel to be installed on the system. It provides a simple and intuitive API that makes it easy for developers to get started with Excel programming.
Where can I get this Excel .Net Library?
You can install Xceed Workbooks for .NET from the Xceed website or through NuGet. To install Xceed Workbooks from NuGet, simply search for “Xceed Workbooks” in the NuGet Package Manager, select the desired version, and install it in your project.
Code snippets
Let’s jump right into it, how to get started with this Excel .NET Library, you will see, it’s incredibly simple to use.
Let’s start with the basics, how to create a workbook?
using (var workbook = Xceed.Workbooks.NET.Workbook.Create("MyWorkbook.xlsx"))
{
var worksheet = workbook.Worksheets.Add("Test Sheet");
// Add some data to the worksheet
worksheet.Cells["A1"].Value = "Name";
worksheet.Cells["B1"].Value = "Age";
worksheet.Cells["A2"].Value = "John";
worksheet.Cells["B2"].Value = "32";
workbook.Save();
}
That’s it, you are now ready to modify your own Workbook through code, no other Excel .Net Libary are easier to use!
The following code snippet demonstrates how to read data from an existing Excel workbook using Xceed Workbooks for .NET:
using (var workbook = Xceed.Workbooks.NET.Workbook.Load("MyWorkbook.xlsx"))
{
var worksheet = workbook.Worksheets[1];
// Read data from the worksheet
var name = worksheet.Cells["A2"].Value.ToString();
var age = worksheet.Cells["B2"].Value.ToString();
Console.WriteLine("his name is " + name + " he is " + age + " years old");
}
The following code snippet demonstrates how to modify an existing Excel workbook using Xceed Workbooks for .NET:
using (var workbook = Xceed.Workbooks.NET.Workbook.Load("MyWorkbook.xlsx"))
{
// Get the first worksheet
var worksheet = workbook.Worksheets[1];
// Modify data in the worksheet
worksheet.Cells["A1"].Value = "Full Name";
worksheet.Cells["B1"].Value = "Years";
// Save the workbook
workbook.Save();
}
So far, in this Excel .Net Library, we’ve seen some very basic “boiler plate” stuff, but the library offers much much more. For example, here’s come code that shows how to create a data table inside an excel worksheet :
using (var workbook = Xceed.Workbooks.NET.Workbook.Create("MyWorkbook.xlsx"))
{
var worksheetA = workbook.Worksheets[0];
// Fill cells values
worksheetA.Rows[4].Cells[6].Value = "Fruits";
worksheetA.Rows[5].Cells[6].Value = "Strawberry";
worksheetA.Rows[6].Cells[6].Value = "Orange";
worksheetA.Rows[7].Cells[6].Value = "Banana";
worksheetA.Rows[8].Cells[6].Value = "Apple";
worksheetA.Rows[4].Cells[7].Value = "Quantity";
worksheetA.Rows[5].Cells[7].Value = 8;
worksheetA.Rows[6].Cells[7].Value = 2;
worksheetA.Rows[7].Cells[7].Value = 3;
worksheetA.Rows[8].Cells[7].Value = 3;
// Creates the formatted table from cell (4,6) to cell (8,7), using a medium theme, with the formatted header row displayed.
worksheetA.Tables.Add(4, 6, 8, 7, Xceed.Workbooks.NET.TableStyle.TableStyleMedium20, true);
// Gets this formatted table and sets some properties. Tables and TableColumns can be accessed by position or name.
worksheetA.Tables[0].ShowFirstColumnFormatting = true;
worksheetA.Tables[0].ShowBandedRows = true;
worksheetA.Tables[0].AutoFilter.ShowFilterButton = false;
worksheetA.Tables["Table1"].ShowTotalRow = true;
worksheetA.Tables["Table1"].Columns["Fruits"].TotalRowLabel = "TOTAL:";
worksheetA.Tables["Table1"].Columns["Quantity"].TotalRowFunction = Xceed.Workbooks.NET.TotalRowFunction.Sum;
workbook.Save();
}
Using Xceed Workbooks, allows you to explore much more, here’s another example of what you can do with our Excel .Net libary.
“Are you looking for an easy way to add pictures to your Excel documents? With the help of our Excel .NET Library, you can easily incorporate images into your Excel worksheets. This can be particularly useful if you’re trying to add a company logo or other graphic element to your worksheet. Here’s a step-by-step guide on how to add a picture to your Excel document using the Excel .NET Library.
To get started, you’ll need to create a new Excel workbook using the Excel .NET Library. Once you’ve created your workbook, you can then add a picture to one of your worksheets using the following code:
using (var workbook = Xceed.Workbooks.NET.Workbook.Create("test.xlsx"))
{
// Get the first worksheet. A workbook contains at least 1 worksheet.
var worksheet = workbook.Worksheets[0];
// Open the picture file as a stream
var stream = new FileStream(PictureSampleResourcesDirectory + @"balloon.jpg", FileMode.Open, FileAccess.Read);
// Add the stream picture in cell A4 and extend it to cell E12.
var filenamePicture = worksheet.Pictures.Add(stream, "A4", "E12");
// Add the filename picture with its top left corner in 15th row and 1st column.
var streamPicture = worksheet.Pictures.Add(PictureSampleResourcesDirectory + @"balloon.jpg", 14, 0);
// Save the workbook
workbook.Save();
}
This code opens the Excel workbook named “test.xlsx” and gets the first worksheet in the workbook. It then creates a FileStream object to open the picture file as a stream. The code then adds the picture to the worksheet by specifying the cell range where the picture should be inserted, and saves the changes to the workbook.
By using the Excel .NET Library to add pictures to your Excel documents, you can enhance the visual appeal of your worksheets and make them more engaging for your users. With just a few lines of code, you can add pictures to your Excel documents with ease, and take advantage of the powerful capabilities offered by the Excel .NET Library.
Conclusion
In conclusion, Xceed Workbooks for .NET is a powerful Excel .NET library that provides developers with a comprehensive set of features for working with Excel files in .NET applications. With Xceed Workbooks, you can handle large amounts of data quickly and efficiently, making it an ideal tool for data analysis and reporting. Whether you’re building a data analysis tool or a financial modeling application, Xceed Workbooks can help you get the job done quickly and efficiently. So if you’re looking for a powerful Excel .NET library, Xceed Workbooks is definitely worth considering.
Ready to start using the Excel .NET Library to enhance your Excel documents? Visit our website to learn more about Xceed Workbooks for .NET, the powerful library that allows you to easily create, edit, and manipulate Excel documents using .NET code. You can purchase the library directly from our website at https://xceed.com/en/our-products/product/workbooks-for-net and get started with adding images, formatting tables, and much more to your Excel documents today!