Initial commit of the ClosedXML library
Establishes the foundational structure, core Excel functionality, and tooling. - Implements base components for cells, ranges, columns, and rows. - Integrates a custom calculation engine with a wide range of Excel functions. - Adds comprehensive support for styling, conditional formatting, data validation, comments, pictures, and charts. - Configures build setup, project metadata (NuGet), and developer guidelines. - Includes editor and Git attributes for consistent code style and line endings.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using ClosedXML.Excel;
|
||||
using ClosedXML_Examples.Tables;
|
||||
using System.IO;
|
||||
|
||||
namespace ClosedXML_Examples.Misc
|
||||
{
|
||||
public class CopyingWorksheets : IXLExample
|
||||
{
|
||||
public void Create(string filePath)
|
||||
{
|
||||
string tempFile1 = ExampleHelper.GetTempFilePath(filePath);
|
||||
string tempFile2 = ExampleHelper.GetTempFilePath(filePath);
|
||||
try
|
||||
{
|
||||
new UsingTables().Create(tempFile1);
|
||||
var wb = new XLWorkbook(tempFile1);
|
||||
|
||||
var wsSource = wb.Worksheet(1);
|
||||
// Copy the worksheet to a new sheet in this workbook
|
||||
wsSource.CopyTo("Copy");
|
||||
|
||||
// We're going to open another workbook to show that you can
|
||||
// copy a sheet from one workbook to another:
|
||||
new BasicTable().Create(tempFile2);
|
||||
var wbSource = new XLWorkbook(tempFile2);
|
||||
wbSource.Worksheet(1).CopyTo(wb, "Copy From Other");
|
||||
|
||||
// Save the workbook with the 2 copies
|
||||
wb.SaveAs(filePath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(tempFile1))
|
||||
{
|
||||
File.Delete(tempFile1);
|
||||
}
|
||||
if (File.Exists(tempFile2))
|
||||
{
|
||||
File.Delete(tempFile2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user