Skip to content

Instantly share code, notes, and snippets.

@aspose-cells-gists
Last active February 22, 2024 10:20
Show Gist options
  • Save aspose-cells-gists/88c9872508ec3150c552eb5155edf06e to your computer and use it in GitHub Desktop.
Save aspose-cells-gists/88c9872508ec3150c552eb5155edf06e to your computer and use it in GitHub Desktop.
Aspose.Cells for .NET
This gist exceeds the recommended number of files (~10). To access all files, please clone this gist.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = "";
if (!System.IO.Directory.Exists(dataDir))
{
System.IO.Directory.CreateDirectory(dataDir);
}
// Open an Excel file.
//Workbook workbook = new Workbook(dataDir+ "Book_SourceData.xlsx");//If you want to insert a text box in an existing file, use this code.
// Create an object of the Workbook class
Workbook workbook = new Workbook();
// Access first worksheet from the collection
Worksheet sheet = workbook.Worksheets[0];
// Add the TextBox to the worksheet
sheet.TextBoxes.Add(6, 10, 100, 200);
//Save.You can check your text box in this way.
workbook.Save("result.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = "";
if (!System.IO.Directory.Exists(dataDir))
{
System.IO.Directory.CreateDirectory(dataDir);
}
//Instantiating a Workbook object
Workbook workbook = new Workbook();
ShapeCollection shapes = workbook.Worksheets[0].Shapes;
//add a TextBox
Shape shape = shapes.AddTextBox(2, 0, 2, 0, 50, 120);
shape.Text = "This is a test.";
//set alignment
shape.TextHorizontalAlignment = TextAlignmentType.Center;
shape.TextVerticalAlignment = TextAlignmentType.Center;
//Save the excel file.
workbook.Save(dataDir + "result.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Intialize an object of the Workbook class to load template file
Workbook sourceWb = new Workbook("SampleTextboxExcel2016.xlsx");
// Access the target textbox whose text is to be aligned
var sourceTextBox = sourceWb.Worksheets[0].Shapes[0];
// Create and object of the target workbook
var destWb = new Workbook();
// Access first worksheet from the collection
var _sheet = destWb.Worksheets[0];
//Create new textbox
TextBox _textBox = (TextBox)_sheet.Shapes.AddShape( MsoDrawingType.TextBox,1, 0, 1, 0, 200, 200);
// Alternatively text box can be added using following line as well
// TextBox _textBox = _sheet.Shapes.AddTextBox(1, 0, 1, 0, 200, 200);
// Use Html string from a template file textbox
_textBox.HtmlText = sourceTextBox.HtmlText;
// Save the workbook on disc
destWb.Save("Output.xlsx");
This Gist contains code example snippets for Aspose.Cells for .NET.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file containing the chart.
Workbook wb = new Workbook(sourceDir + "sampleCreateChartPDFWithDesiredPageSize.xlsx");
//Access first worksheet.
Worksheet ws = wb.Worksheets[0];
//Access first chart inside the worksheet.
Chart ch = ws.Charts[0];
//Create chart pdf with desired page size.
ch.ToPdf(outputDir + "outputCreateChartPDFWithDesiredPageSize.pdf", 7, 7, PageLayoutAlignmentType.Center, PageLayoutAlignmentType.Center);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file containing chart.
Workbook wb = new Workbook(sourceDir + "sampleFindTypeOfXandYValuesOfPointsInChartSeries.xlsx");
//Access first worksheet.
Worksheet ws = wb.Worksheets[0];
//Access first chart.
Chart ch = ws.Charts[0];
//Calculate chart data.
ch.Calculate();
//Access first chart point in the first series.
ChartPoint pnt = ch.NSeries[0].Points[0];
//Print the types of X and Y values of chart point.
Console.WriteLine("X Value Type: " + pnt.XValueType);
Console.WriteLine("Y Value Type: " + pnt.YValueType);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the sample Excel file
Workbook wb = new Workbook("sampleHandleAutomaticUnitsOfChartAxisLikeMicrosoftExcel.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access first chart
Chart ch = ws.Charts[0];
//Render chart to pdf
ch.ToPdf("outputHandleAutomaticUnitsOfChartAxisLikeMicrosoftExcel.pdf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the Excel file containing chart
Workbook wb = new Workbook("sampleReadAxisLabelsAfterCalculatingTheChart.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access the chart
Chart ch = ws.Charts[0];
//Calculate the chart
ch.Calculate();
//Read axis labels of category axis
ArrayList lstLabels = ch.CategoryAxis.AxisLabels;
//Print axis labels on console
Console.WriteLine("Category Axis Labels: ");
Console.WriteLine("---------------------");
//Iterate axis labels and print them one by one
for (int i = 0; i < lstLabels.Count; i++)
{
Console.WriteLine(lstLabels[i]);
}
Workbook workbook = new Workbook("SourceExcel.xls");
workbook.Save("outputExcel.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a new Workbook
Workbook wb = new Workbook();
//Get the first Worksheet
Worksheet sheet = wb.Worksheets[0];
//Open the file stream and add it to the excel file
using (Stream bmpFile = File.Open("bmptoexcel.bmp", FileMode.Open))
{
sheet.Shapes.AddPicture(0, 0, bmpFile, 100, 100);
}
// Save the workbook in output XLSX format.
wb.Save("bmptoexcel.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.csv");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a new Workbook
Workbook wb = new Workbook();
//Get the first Worksheet
Worksheet sheet = wb.Worksheets[0];
//Open the file stream and add it to the excel file
using (Stream emfFile = File.Open("emftoexcel.emf", FileMode.Open))
{
sheet.Shapes.AddPicture(0, 0, emfFile, 100, 100);
}
// Save the workbook in output XLSX format.
wb.Save("emftoexcel.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
using Aspose.Cells;
using Aspose.Cells.Rendering;
//"Book1.xlsx" is an excel file which contains an equation object.
Workbook wb = new Workbook("Book1.xlsx");
Worksheet ws0 = wb.Worksheets[0];
ws0.Shapes[0].ToImage("Equation.png", new ImageOrPrintOptions());
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Bmp;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
int pageCount = sr.PageCount;
for (int idxPage = 0; idxPage < pageCount; idxPage++)
{
// Save the image file
sr.ToImage(idxPage, "out_" + (idxPage + 1) + ".bmp");
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Bmp;
// All content of one sheet will output to only one page in result
imgOptions.OnePagePerSheet = true;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
//save the whole worksheet to image
sr.ToImage(0, "out_currSheet.bmp");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to CSV format
workbook.Save("out.csv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to dif format
workbook.Save("out.dif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to docx format
workbook.Save("out.docx", SaveFormat.Docx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Emf;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
int pageCount = sr.PageCount;
for (int idxPage = 0; idxPage < pageCount; idxPage++)
{
// Save the image file
sr.ToImage(idxPage, "out_" + (idxPage + 1) + ".emf");
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Emf;
// All content of one sheet will output to only one page in result
imgOptions.OnePagePerSheet = true;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
//save the whole worksheet to image
sr.ToImage(0, "out_currSheet.emf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to fods format
workbook.Save("out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to html format
workbook.Save("out.html");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to BMP image.
book.Save("Image1.bmp");
//Convert workbook to JPG image.
book.Save("Image1.jpg");
//Convert workbook to Png image.
book.Save("Image1.png");
//Convert workbook to EMF image.
book.Save("Image1.emf");
//Convert workbook to GIF image.
book.Save("Image1.gif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to JPG image.
book.Save("Image1.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Jpeg;
// All content of one sheet will output to only one page in result
imgOptions.OnePagePerSheet = true;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
//save the whole worksheet to image
sr.ToImage(0, "out_currSheet.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("sample.xlsx");
//Convert the workbook to json file.
workbook.Save("sample_out.json");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create an options of saving the file.
JsonSaveOptions options = new JsonSaveOptions();
//Set the exporting range.
options.ExportArea = CellArea.CreateCellArea("B1", "C4");
//Load your source workbook
Workbook workbook = new Workbook("sample.xlsx");
//Convert the workbook to json file.
workbook.Save("sample_out.json", options);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
// convert the workbook to json file.
workbook.Save(dir + "book1.json");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to mhtml format
workbook.Save("out.mht");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("book1.xlsx");
// Save as ods file
workbook.Save("Out.ods");
// Save as sxc file
workbook.Save("Out.sxc");
// Save as fods file
workbook.Save("Out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Instantiate the Workbook object
// Open an Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Save the document in PDF format
workbook.Save("output.pdf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Png;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
int pageCount = sr.PageCount;
for (int idxPage = 0; idxPage < pageCount; idxPage++)
{
// Save the image file
sr.ToImage(idxPage, "out_" + (idxPage + 1) + ".png");
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Specify the image format
imgOptions.ImageType = ImageType.Png;
// All content of one sheet will output to only one page in result
imgOptions.OnePagePerSheet = true;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
//save the whole worksheet to image
sr.ToImage(0, "out_currSheet.png");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//save file to svg
book.Save("out.svg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to sxc format
workbook.Save("out.sxc");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//save file to tiff
book.Save("out.tiff");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//save file to TSV format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//Save as Excel 2003 Spreadsheet XML
workbook.Save("Spreadsheet.xml");
//Save as plain XML data
XmlSaveOptions xmlSaveOptions = new XmlSaveOptions();
workbook.Save("data.xml", xmlSaveOptions);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//save file to xps
book.Save("out.xps");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to fods format
workbook.Save("out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to mhtml format
workbook.Save("out.mhtml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.fods");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.html");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.jpeg");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.jpg");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a new Workbook
Workbook wb = new Workbook();
// Access the first worksheet.
Worksheet sheet = wb.Worksheets[0];
// Get the file stream and add it to the excel file
using (Stream jpgFile = File.Open("test.jpg", FileMode.Open))
{
sheet.Shapes.AddPicture(0, 0, jpgFile, 100, 100);
}
// Save the workbook in output XLSX format.
wb.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.json");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// create a Workbook object
Workbook wb = new Workbook("sample.json");
//save file to xlsx format
wb.Save("sample_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create an options of loading the file.
JsonLoadOptions options = new JsonLoadOptions();
//Indicates whether importing each attribute of JsonObject object as one worksheet when all child nodes are array nodes.
options.MultipleWorksheets = true;
Workbook book = new Workbook("sample.json", options);
//save file to xlsx format
book.Save("sample_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// create a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// read JSON data from file
string jsonInput = File.ReadAllText("Book1.json");
// set JsonLayoutOptions to treat Arrays as Table
JsonLayoutOptions options = new JsonLayoutOptions();
options.ArrayAsTable = true;
// import JSON data to worksheet starting at cell A1
JsonUtility.ImportData(jsonInput, worksheet.Cells, 0, 0, options);
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mht");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.mhtml");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to bmp format
workbook.Save("out.bmp");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to csv format
workbook.Save("out.csv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to dif format
workbook.Save("out.dif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to emf format
workbook.Save("out.emf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to fods format
workbook.Save("out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to gif format
workbook.Save("out.gif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to html format
workbook.Save("out.html");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to mhtml format
workbook.Save("out.mhtml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to ods format
workbook.Save("out.ods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to pdf format
workbook.Save("out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to png format
workbook.Save("out.png");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to svg format
workbook.Save("out.svg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to sxc format
workbook.Save("out.sxc");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to tiff format
workbook.Save("out.tiff");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to txt format
workbook.Save("out.txt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlam format
workbook.Save("out.xlam");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xls format
workbook.Save("out.xls");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlsb format
workbook.Save("out.xlsb");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlsm format
workbook.Save("out.xlsm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xlt format
workbook.Save("out.xlt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xltm format
workbook.Save("out.xltm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xltx format
workbook.Save("out.xltx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.numbers");
//save file to xps format
workbook.Save("out.xps");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source ods file
Workbook workbook = new Workbook("book1.ods");
//Save as xlsx file
workbook.Save("ods_out.xlsx");
//Load your source sxc file
workbook = new Workbook("book1.sxc");
//Save as xls file
workbook.Save("sxc_out.xls");
//Load your source fods file
workbook = new Workbook("book1.fods");
//Save as xlsb file
workbook.Save("fods_out.xlsb");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.ods");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a new Workbook
Workbook wb = new Workbook();
//Get the first Worksheet
Worksheet sheet = wb.Worksheets[0];
//Open the file stream and add it to the excel file
using (Stream pngFile = File.Open("pngtoexcel.png", FileMode.Open))
{
sheet.Shapes.AddPicture(0, 0, pngFile, 100, 100);
}
// Save the workbook in output XLSX format.
wb.Save("pngtoexcel.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a new Workbook
Workbook wb = new Workbook();
//Get the first Worksheet
Worksheet sheet = wb.Worksheets[0];
//Get bytes of svg image
byte[] svgBytes = File.ReadAllBytes("svgtoexcel.svg");
sheet.Shapes.AddSvg(0, 0, 0, 0, -1, -1, svgBytes, null);
// Save the workbook in output XLSX format.
wb.Save("svgtoexcel.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to mhtml format
workbook.Save("out.mhtml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.sxc");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
Workbook wb = new Workbook();
//Get the first Worksheet
Worksheet sheet = wb.Worksheets[0];
//Open the file stream and add it to the excel file
using (Stream tiffFile = File.Open("tifftoexcel.tiff", FileMode.Open))
{
sheet.Shapes.AddPicture(0, 0, tiffFile, 100, 100);
}
// Save the workbook in output XLSX format.
wb.Save("tifftoexcel.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to bmp format
workbook.Save("out.bmp");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to csv format
workbook.Save("out.csv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to dif format
workbook.Save("out.dif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to emf format
workbook.Save("out.emf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to fods format
workbook.Save("out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to gif format
workbook.Save("out.gif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to html format
workbook.Save("out.html");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to mhtml format
workbook.Save("out.mhtml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to ods format
workbook.Save("out.ods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to pdf format
workbook.Save("out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to png format
workbook.Save("out.png");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to svg format
workbook.Save("out.svg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to sxc format
workbook.Save("out.sxc");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to tiff format
workbook.Save("out.tiff");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to txt format
workbook.Save("out.txt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlam format
workbook.Save("out.xlam");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xls format
workbook.Save("out.xls");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlsb format
workbook.Save("out.xlsb");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlsm format
workbook.Save("out.xlsm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xlt format
workbook.Save("out.xlt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xltm format
workbook.Save("out.xltm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xltx format
workbook.Save("out.xltx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.tsv");
//save file to xps format
workbook.Save("out.xps");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.txt");
//save file to xml format
workbook.Save("out.xml");
Workbook wb = new Workbook("workbook-to-tiff-with-mulitiple-pages.xlsx");
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageType = ImageType.Tiff;
//set Resolution to 200
imgOptions.HorizontalResolution = 200;
imgOptions.VerticalResolution = 200;
//set TIFF compression to Lzw.
imgOptions.TiffCompression = TiffCompression.CompressionLZW;
WorkbookRender workbookRender = new WorkbookRender(wb, imgOptions);
workbookRender.ToImage("workbook-to-tiff-with-mulitiple-pages.tiff");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to pptx format
workbook.Save("out.pptx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to sql format
workbook.Save("out.sql");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xls");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsb");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsm");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to pptx format
workbook.Save("out.pptx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to sql format
workbook.Save("out.sql");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlsx");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xlt");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltm");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xltx");
//save file to xml format
workbook.Save("out.xml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to bmp format
workbook.Save("out.bmp");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to csv format
workbook.Save("out.csv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to dif format
workbook.Save("out.dif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to docx format
workbook.Save("out.docx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to emf format
workbook.Save("out.emf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to fods format
workbook.Save("out.fods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to gif format
workbook.Save("out.gif");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to html format
workbook.Save("out.html");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to jpeg format
workbook.Save("out.jpeg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to jpg format
workbook.Save("out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to md format
workbook.Save("out.md");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to mhtml format
workbook.Save("out.mhtml");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to ods format
workbook.Save("out.ods");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to pdf format
workbook.Save("out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to png format
workbook.Save("out.png");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to svg format
workbook.Save("out.svg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to sxc format
workbook.Save("out.sxc");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to tiff format
workbook.Save("out.tiff");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to tsv format
workbook.Save("out.tsv");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to txt format
workbook.Save("out.txt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlam format
workbook.Save("out.xlam");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xls format
workbook.Save("out.xls");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlsb format
workbook.Save("out.xlsb");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlsm format
workbook.Save("out.xlsm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlsx format
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xlt format
workbook.Save("out.xlt");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xltm format
workbook.Save("out.xltm");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xltx format
workbook.Save("out.xltx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source file
Workbook workbook = new Workbook("Book1.xml");
//save file to xps format
workbook.Save("out.xps");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Load sample Excel file containing cells with formatting.
Workbook wb = new Workbook(sourceDir + "sampleChangeCellsAlignmentAndKeepExistingFormatting.xlsx");
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Create cells range.
Range rng = ws.Cells.CreateRange("B2:D7");
// Create style object.
Style st = wb.CreateStyle();
// Set the horizontal and vertical alignment to center.
st.HorizontalAlignment = TextAlignmentType.Center;
st.VerticalAlignment = TextAlignmentType.Center;
// Create style flag object.
StyleFlag flag = new StyleFlag();
// Set style flag alignments true. It is most crucial statement.
// Because if it will be false, no changes will take place.
flag.Alignments = true;
// Apply style to range of cells.
rng.ApplyStyle(st, flag);
// Save the workbook in XLSX format.
wb.Save(outputDir + "outputChangeCellsAlignmentAndKeepExistingFormatting.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create empty workbook.
Workbook wb = new Workbook();
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Create range A1:B3.
Console.WriteLine("Creating Range A1:B3\n");
Range rng = ws.Cells.CreateRange("A1:B3");
// Print range address and cell count.
Console.WriteLine("Range Address: " + rng.Address);
Console.WriteLine("Range row Count: " + rng.RowCount);
Console.WriteLine("Range column Count: " + rng.ColumnCount);
// Formatting console output.
Console.WriteLine("----------------------");
Console.WriteLine("");
// Create range A1.
Console.WriteLine("Creating Range A1\n");
rng = ws.Cells.CreateRange("A1");
// Print range offset, entire column and entire row.
Console.WriteLine("Offset: " + rng.GetOffset(2, 2).Address);
Console.WriteLine("Entire Column: " + rng.EntireColumn.Address);
Console.WriteLine("Entire Row: " + rng.EntireRow.Address);
// Formatting console output.
Console.WriteLine("----------------------");
Console.WriteLine("");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the sample Excel file
Workbook wb = new Workbook(sourceDir + "sampleGetAllHiddenRowsIndicesAfterRefreshingAutoFilter.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Apply autofilter
ws.AutoFilter.AddFilter(0, "Orange");
//True means, it will refresh autofilter and return hidden rows.
//False means, it will not refresh autofilter but return same hidden rows.
int[] rowIndices = ws.AutoFilter.Refresh(true);
Console.WriteLine("Printing Rows Indices, Cell Names and Values Hidden By AutoFilter.");
Console.WriteLine("--------------------------");
for (int i = 0; i < rowIndices.Length; i++)
{
int r = rowIndices[i];
Cell cell = ws.Cells[r, 0];
Console.WriteLine(r + "\t" + cell.Name + "\t" + cell.StringValue);
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create workbook
Workbook wb = new Workbook();
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access cell A1
Cell cell = ws.Cells["A1"];
//Put some text in cell, it does not have Single Quote at the beginning
cell.PutValue("Text");
//Access style of cell A1
Style st = cell.GetStyle();
//Print the value of Style.QuotePrefix of cell A1
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix);
//Put some text in cell, it has Single Quote at the beginning
cell.PutValue("'Text");
//Access style of cell A1
st = cell.GetStyle();
//Print the value of Style.QuotePrefix of cell A1
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix);
//Print information about StyleFlag.QuotePrefix property
Console.WriteLine();
Console.WriteLine("When StyleFlag.QuotePrefix is False, it means, do not update the value of Cell.Style.QuotePrefix.");
Console.WriteLine("Similarly, when StyleFlag.QuotePrefix is True, it means, update the value of Cell.Style.QuotePrefix.");
Console.WriteLine();
//Create an empty style
st = wb.CreateStyle();
//Create style flag - set StyleFlag.QuotePrefix as false
//It means, we do not want to update the Style.QuotePrefix property of cell A1's style.
StyleFlag flag = new StyleFlag();
flag.QuotePrefix = false;
//Create a range consisting of single cell A1
Range rng = ws.Cells.CreateRange("A1");
//Apply the style to the range
rng.ApplyStyle(st, flag);
//Access the style of cell A1
st = cell.GetStyle();
//Print the value of Style.QuotePrefix of cell A1
//It will print True, because we have not updated the Style.QuotePrefix property of cell A1's style.
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix);
//Create an empty style
st = wb.CreateStyle();
//Create style flag - set StyleFlag.QuotePrefix as true
//It means, we want to update the Style.QuotePrefix property of cell A1's style.
flag = new StyleFlag();
flag.QuotePrefix = true;
//Apply the style to the range
rng.ApplyStyle(st, flag);
//Access the style of cell A1
st = cell.GetStyle();
//Print the value of Style.QuotePrefix of cell A1
//It will print False, because we have updated the Style.QuotePrefix property of cell A1's style.
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Aspose.Cells.Examples.CSharp.Data
{
class SpecifyFormulaFieldsWhileImportingDataToWorksheet
{
//Output directory
static string outputDir = RunExamples.Get_OutputDirectory();
//User-defined class to hold data items
class DataItems
{
public int Number1 { get; set; }
public int Number2 { get; set; }
public string Formula1 { get; set; }
public string Formula2 { get; set; }
}
public static void Run()
{
//List to hold data items
List<DataItems> dis = new List<DataItems>();
//Define 1st data item and add it in list
DataItems di = new DataItems();
di.Number1 = 2002;
di.Number2 = 3502;
di.Formula1 = "=SUM(A2,B2)";
di.Formula2 = "=HYPERLINK(\"https://www.aspose.com\",\"Aspose Website\")";
dis.Add(di);
//Define 2nd data item and add it in list
di = new DataItems();
di.Number1 = 2003;
di.Number2 = 3503;
di.Formula1 = "=SUM(A3,B3)";
di.Formula2 = "=HYPERLINK(\"https://www.aspose.com\",\"Aspose Website\")";
dis.Add(di);
//Define 3rd data item and add it in list
di = new DataItems();
di.Number1 = 2004;
di.Number2 = 3504;
di.Formula1 = "=SUM(A4,B4)";
di.Formula2 = "=HYPERLINK(\"https://www.aspose.com\",\"Aspose Website\")";
dis.Add(di);
//Define 4th data item and add it in list
di = new DataItems();
di.Number1 = 2005;
di.Number2 = 3505;
di.Formula1 = "=SUM(A5,B5)";
di.Formula2 = "=HYPERLINK(\"https://www.aspose.com\",\"Aspose Website\")";
dis.Add(di);
//Create workbook object
Workbook wb = new Workbook();
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Specify import table options
ImportTableOptions opts = new ImportTableOptions();
//Specify which field is formula field, here the last two fields are formula fields
opts.IsFormulas = new bool[] { false, false, true, true };
//Import custom objects
ws.Cells.ImportCustomObjects(dis, 0, 0, opts);
//Calculate formula
wb.CalculateFormula();
//Autofit columns
ws.AutoFitColumns();
//Save the output Excel file
wb.Save(outputDir + "outputSpecifyFormulaFieldsWhileImportingDataToWorksheet.xlsx");
Console.WriteLine("SpecifyFormulaFieldsWhileImportingDataToWorksheet executed successfully.");
}
}
}
//Open encrypted file with password.
LoadOptions loadOptions = new LoadOptions();
loadOptions.Password = "password";
Workbook workbook = new Workbook("Book1.xlsx", loadOptions);
//Remove password.
workbook.Settings.Password = null;
//Save the file.
workbook.Save("Book1.xlsx");
//Creates a new file.
var wb = new Workbook();
//Gets the setting of page setup.
PageSetup pageSetup = wb.Worksheets[0].PageSetup;
//Sets different odd and even pages
pageSetup.IsHFDiffOddEven = true;
pageSetup.SetHeader(1, "I am the header of the Odd page.");
pageSetup.SetEvenHeader(1, "I am the header of the Even page.");
//Sets different first page
pageSetup.IsHFDiffFirst = true;
pageSetup.SetFirstPageHeader(1, "I am the header of the First page.");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create workbook object.
Workbook wb = new Workbook();
//Access built-in document property collection.
Aspose.Cells.Properties.BuiltInDocumentPropertyCollection bdpc = wb.BuiltInDocumentProperties;
//Set the language of the Excel file.
bdpc.Language = "German, French";
//Save the workbook in xlsx format.
wb.Save(outputDir + "outputSpecifyLanguageOfExcelFileUsingBuiltInDocumentProperties.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the sample Excel file
Workbook wb = new Workbook("sampleAccessAndModifyLabelOfOleObject.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access first Ole Object
Aspose.Cells.Drawing.OleObject oleObject = ws.OleObjects[0];
//Display the Label of the Ole Object
Console.WriteLine("Ole Object Label - Before: " + oleObject.Label);
//Modify the Label of the Ole Object
oleObject.Label = "Aspose APIs";
//Save workbook to memory stream
MemoryStream ms = new MemoryStream();
wb.Save(ms, SaveFormat.Xlsx);
//Set the workbook reference to null
wb = null;
//Load workbook from memory stream
wb = new Workbook(ms);
//Access first worksheet
ws = wb.Worksheets[0];
//Access first Ole Object
oleObject = ws.OleObjects[0];
//Display the Label of the Ole Object that has been modified earlier
Console.WriteLine("Ole Object Label - After: " + oleObject.Label);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Load sample Excel file containing gear type smart art shape.
Workbook wb = new Workbook("sampleExtractTextFromGearTypeSmartArtShape.xlsx");
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Access first shape.
Aspose.Cells.Drawing.Shape sh = ws.Shapes[0];
// Get the result of gear type smart art shape in the form of group shape.
Aspose.Cells.Drawing.GroupShape gs = sh.GetResultOfSmartArt();
// Get the list of individual shapes consisting of group shape.
Aspose.Cells.Drawing.Shape[] shps = gs.GetGroupedShapes();
// Extract the text of gear type shapes and print them on console.
for (int i = 0; i < shps.Length; i++)
{
Aspose.Cells.Drawing.Shape s = shps[i];
if (s.Type == Aspose.Cells.Drawing.AutoShapeType.Gear9 || s.Type == Aspose.Cells.Drawing.AutoShapeType.Gear6)
{
Console.WriteLine("Gear Type Shape Text: " + s.Text);
}
}//for
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file.
Workbook wb = new Workbook(sourceDir + "sampleRotateTextWithShapeInsideWorksheet.xlsx");
//Access first worksheet.
Worksheet ws = wb.Worksheets[0];
//Access cell B4 and add message inside it.
Cell b4 = ws.Cells["B4"];
b4.PutValue("Text is not rotating with shape because RotateTextWithShape is false.");
//Access first shape.
Shape sh = ws.Shapes[0];
//Access shape text alignment.
Aspose.Cells.Drawing.Texts.ShapeTextAlignment shapeTextAlignment = sh.TextBody.TextAlignment;
//Do not rotate text with shape by setting RotateTextWithShape as false.
shapeTextAlignment.RotateTextWithShape = false;
//Save the output Excel file.
wb.Save(outputDir + "outputRotateTextWithShapeInsideWorksheet.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the sample Excel file
Workbook wb = new Workbook("sampleSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
foreach (Shape sh in ws.Shapes)
{
//Access the text alignment
Aspose.Cells.Drawing.Texts.ShapeTextAlignment txtAlign = sh.TextBody.TextAlignment;
//Set auto margin false
txtAlign.IsAutoMargin = false;
//Set the top, left, bottom and right margins
txtAlign.TopMarginPt = 10;
txtAlign.LeftMarginPt = 10;
txtAlign.BottomMarginPt = 10;
txtAlign.RightMarginPt = 10;
}
//Save the output Excel file
wb.Save("outputSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create empty workbook.
Workbook wb = new Workbook();
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Add textbox inside the worksheet.
int idx = ws.TextBoxes.Add(5, 5, 50, 200);
Aspose.Cells.Drawing.TextBox tb = ws.TextBoxes[idx];
// Set the text of the textbox.
tb.Text = "こんにちは世界";
// Specify the Far East and Latin name of the font.
tb.TextOptions.LatinName = "Comic Sans MS";
tb.TextOptions.FarEastName = "KaiTi";
// Save the output Excel file.
wb.Save("outputSpecifyFarEastAndLatinNameOfFontInTextOptionsOfShape.xlsx", SaveFormat.Xlsx);
//Create a new file.
Workbook workbook = new Workbook();
//Protect workbook structure.
workbook.Protect(ProtectionType.Structure, "password");
//Save Excel file.
workbook.Save("Book1.xlsx");
//Create a new file.
Workbook workbook = new Workbook();
//Gets the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Protect contents of the worksheet.
sheet.Protect(ProtectionType.Contents);
//Protect worksheet with password.
sheet.Protection.Password = "test";
//Save as Excel file.
workbook.Save("Book1.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create empty workbook.
Workbook wb = new Workbook();
// Some data in the form of byte array.
// Please use correct XML and Schema instead.
byte[] btsData = new byte[] { 1, 2, 3 };
byte[] btsSchema = new byte[] { 1, 2, 3 };
// Create four custom xml parts.
wb.CustomXmlParts.Add(btsData, btsSchema);
wb.CustomXmlParts.Add(btsData, btsSchema);
wb.CustomXmlParts.Add(btsData, btsSchema);
wb.CustomXmlParts.Add(btsData, btsSchema);
// Assign ids to custom xml parts.
wb.CustomXmlParts[0].ID = "Fruit";
wb.CustomXmlParts[1].ID = "Color";
wb.CustomXmlParts[2].ID = "Sport";
wb.CustomXmlParts[3].ID = "Shape";
// Specify search custom xml part id.
String srchID = "Fruit";
srchID = "Color";
srchID = "Sport";
// Search custom xml part by the search id.
Aspose.Cells.Markup.CustomXmlPart cxp = wb.CustomXmlParts.SelectByID(srchID);
// Print the found or not found message on console.
if (cxp == null)
{
Console.WriteLine("Not Found: CustomXmlPart ID " + srchID);
}
else
{
Console.WriteLine("Found: CustomXmlPart ID " + srchID);
}
Console.WriteLine("AddCustomXMLPartsAndSelectThemByID executed successfully.");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiating a Workbook object
Workbook wb = new Workbook();
PictureCollection pics = wb.Worksheets[0].Pictures;
pics.Add(10, 0,12,1,(Stream)null);
SignatureLine signatureLine = new SignatureLine();
signatureLine.Id = Guid.NewGuid();
signatureLine.ProviderId = Guid.Empty;
signatureLine.Signer = "Aspose.Cells";
signatureLine.Title = "signed by Aspose.Cells";
wb.Worksheets[0].Pictures[0].SignatureLine = signatureLine;
X509Certificate2 certificate = new X509Certificate2(dataDir + "rsa2048.pfx", "123456");
Aspose.Cells.DigitalSignatures.DigitalSignature signature =
new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "test Microsoft Office signature line", DateTime.UtcNow);
signature.Id = signatureLine.Id;
signature.ProviderId = signatureLine.ProviderId;
Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection();
dsCollection.Add(signature);
wb.SetDigitalSignature(dsCollection);
wb.Save(dataDir + "signatureLine.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Read icon resource file data
string fileName = "icon.svg";
FileStream fsSource = File.OpenRead(fileName);
byte[] bytes = new byte[fsSource.Length];
int numBytesToRead = (int)fsSource.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = fsSource.Read(bytes, numBytesRead, numBytesToRead);
// Break when the end of the file is reached.
if (n == 0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
fsSource.Close();
// Create workbook from sample file
Workbook workbook = new Workbook("sample.xlsx");
// Access first worksheet from the collection
Worksheet sheet = workbook.Worksheets[0];
// Add the icon to the worksheet
sheet.Shapes.AddIcons(3, 0, 7, 0, 100, 100, bytes, null);
//Set a prompt message
Cell c = sheet.Cells[8,7];
c.Value = "Insert via Aspose.Cells";
Style s = c.GetStyle();
s.Font.Color = Color.Blue;
c.SetStyle(s);
//Save.You can check your icon in this way.
workbook.Save("sample2.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create an object of the Workbook class
Workbook workbook = new Workbook();
// Access first worksheet from the collection
Worksheet sheet = workbook.Worksheets[0];
// Add the TextBox to the worksheet
int idx = sheet.TextBoxes.Add(10, 10, 10, 10);
// Access newly created TextBox using its index & name it
TextBox tb1 = sheet.TextBoxes[idx];
tb1.Name = "MyTextBox";
// Set text for the TextBox
tb1.Text = "This is MyTextBox";
// Access the same TextBox via its name
TextBox tb2 = sheet.TextBoxes["MyTextBox"];
// Display the text of the TextBox accessed via name
Console.WriteLine(tb2.Text);
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object
Workbook wb = new Workbook();
// Access first worksheet
Worksheet sheet = wb.Worksheets[0];
// Add Toggle Button ActiveX Control inside the Shape Collection
Shape s = sheet.Shapes.AddActiveXControl(ControlType.ToggleButton, 4, 0, 4, 0, 100, 30);
// Access the ActiveX control object and set its linked cell property
ActiveXControl c = s.ActiveXControl;
c.LinkedCell = "A1";
// Save the worbook in xlsx format
wb.Save(dataDir + "AddActiveXControls_out.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a new Workbook
Workbook workbook = new Workbook();
// Get the first worksheet (default worksheet) in the workbook
Worksheet worksheet = workbook.Worksheets[0];
// Get the cells
Cells cells = worksheet.Cells;
// Set the columns widths (A, B and C)
worksheet.Cells.SetColumnWidth(0, 24);
worksheet.Cells.SetColumnWidth(1, 24);
worksheet.Cells.SetColumnWidth(2, 24);
// Input date into the cells
cells["A1"].PutValue("KPIs");
cells["A2"].PutValue("Total Turnover (Sales at List)");
cells["A3"].PutValue("Total Gross Margin %");
cells["A4"].PutValue("Total Net Margin %");
cells["B1"].PutValue("UA Contract Size Group 4");
cells["B2"].PutValue(19551794);
cells["B3"].PutValue(11.8070745566204);
cells["B4"].PutValue(11.858589818569);
cells["C1"].PutValue("UA Contract Size Group 3");
cells["C2"].PutValue(8150131.66666667);
cells["C3"].PutValue(10.3168384396244);
cells["C4"].PutValue(11.3326931937091);
// Get the conditional icon's image data
byte[] imagedata = ConditionalFormattingIcon.GetIconImageData(IconSetType.TrafficLights31, 0);
// Create a stream based on the image data
MemoryStream stream = new MemoryStream(imagedata);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(1, 1, stream);
// Get the conditional icon's image data
byte[] imagedata1 = ConditionalFormattingIcon.GetIconImageData(IconSetType.Arrows3, 2);
// Create a stream based on the image data
MemoryStream stream1 = new MemoryStream(imagedata1);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(1, 2, stream1);
// Get the conditional icon's image data
byte[] imagedata2 = ConditionalFormattingIcon.GetIconImageData(IconSetType.Symbols3, 0);
// Create a stream based on the image data
MemoryStream stream2 = new MemoryStream(imagedata2);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(2, 1, stream2);
// Get the conditional icon's image data
byte[] imagedata3 = ConditionalFormattingIcon.GetIconImageData(IconSetType.Stars3, 0);
// Create a stream based on the image data
MemoryStream stream3 = new MemoryStream(imagedata3);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(2, 2, stream3);
// Get the conditional icon's image data
byte[] imagedata4 = ConditionalFormattingIcon.GetIconImageData(IconSetType.Boxes5, 1);
// Create a stream based on the image data
MemoryStream stream4 = new MemoryStream(imagedata4);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(3, 1, stream4);
// Get the conditional icon's image data
byte[] imagedata5 = ConditionalFormattingIcon.GetIconImageData(IconSetType.Flags3, 1);
// Create a stream based on the image data
MemoryStream stream5 = new MemoryStream(imagedata5);
// Add the picture to the cell based on the stream
worksheet.Pictures.Add(3, 2, stream5);
dataDir = dataDir + "outfile_cond_icons1.out.xlsx";
// Save the Excel file
workbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
public class AddingAnonymousCustomObject
{
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Open a designer workbook
WorkbookDesigner designer = new WorkbookDesigner();
// Get worksheet Cells collection
Cells cells = designer.Workbook.Worksheets[0].Cells;
// Set Cell Values
cells["A1"].PutValue("Name");
cells["B1"].PutValue("Age");
// Set markers
cells["A2"].PutValue("&=Person.Name");
cells["B2"].PutValue("&=Person.Age");
// Create Array list
ArrayList list = new ArrayList();
// Add custom objects to the list
list.Add(new Person("Simon", 30));
list.Add(new Person("Johnson", 33));
// Add designer's datasource
designer.SetDataSource("Person", list);
// Process designer
designer.Process(false);
dataDir = dataDir + "result.out.xls";
// Save the resultant file
designer.Workbook.Save(dataDir);
Console.WriteLine("\nProcess completed successfully.\nFile saved at " + dataDir);
}
}
public class Person
{
public String Name;
public int Age;
internal Person(string name,int age)
{
this.Name = name;
this.Age = age;
}
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object
Workbook workbook = new Workbook(FileFormatType.Xlsx);
// Add simple property without any type
workbook.ContentTypeProperties.Add("MK31", "Simple Data");
// Add date time property with type
workbook.ContentTypeProperties.Add("MK32", "04-Mar-2015", "DateTime");
// Save the workbook
workbook.Save(dataDir + "AddingCustomPropertiesVisible_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a new workbook
Workbook workbook = new Workbook();
// Get the cells in the first(default) worksheet
Cells cells = workbook.Worksheets[0].Cells;
// Get the A1 cell
Aspose.Cells.Cell p = cells["A1"];
// Enter a value
p.PutValue("Preface");
// Get the A10 cell
Aspose.Cells.Cell A = cells["A10"];
// Enter a value.
A.PutValue("page1");
// Get the H15 cell
Aspose.Cells.Cell D = cells["H15"];
// Enter a value
D.PutValue("page1(H15)");
// Add a new worksheet to the workbook
workbook.Worksheets.Add();
// Get the cells in the second sheet
cells = workbook.Worksheets[1].Cells;
// Get the B10 cell in the second sheet
Aspose.Cells.Cell B = cells["B10"];
// Enter a value
B.PutValue("page2");
// Add a new worksheet to the workbook
workbook.Worksheets.Add();
// Get the cells in the third sheet
cells = workbook.Worksheets[2].Cells;
// Get the C10 cell in the third sheet
Aspose.Cells.Cell C = cells["C10"];
// Enter a value
C.PutValue("page3");
// Create a main PDF Bookmark entry object
Aspose.Cells.Rendering.PdfBookmarkEntry pbeRoot = new Aspose.Cells.Rendering.PdfBookmarkEntry();
// Specify its text
pbeRoot.Text = "Sections";
// Set the destination cell/location
pbeRoot.Destination = p;
// Set its sub entry array list
pbeRoot.SubEntry = new ArrayList();
// Create a sub PDF Bookmark entry object
Aspose.Cells.Rendering.PdfBookmarkEntry subPbe1 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
// Specify its text
subPbe1.Text = "Section 1";
// Set its destination cell
subPbe1.Destination = A;
// Define/Create a sub Bookmark entry object of "Section A"
Aspose.Cells.Rendering.PdfBookmarkEntry ssubPbe = new Aspose.Cells.Rendering.PdfBookmarkEntry();
// Specify its text
ssubPbe.Text = "Section 1.1";
// Set its destination
ssubPbe.Destination = D;
// Create/Set its sub entry array list object
subPbe1.SubEntry = new ArrayList();
// Add the object to "Section 1"
subPbe1.SubEntry.Add(ssubPbe);
// Add the object to the main PDF root object
pbeRoot.SubEntry.Add(subPbe1);
// Create a sub PDF Bookmark entry object
Aspose.Cells.Rendering.PdfBookmarkEntry subPbe2 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
// Specify its text
subPbe2.Text = "Section 2";
// Set its destination
subPbe2.Destination = B;
// Add the object to the main PDF root object
pbeRoot.SubEntry.Add(subPbe2);
// Create a sub PDF Bookmark entry object
Aspose.Cells.Rendering.PdfBookmarkEntry subPbe3 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
// Specify its text
subPbe3.Text = "Section 3";
// Set its destination
subPbe3.Destination = C;
// Add the object to the main PDF root object
pbeRoot.SubEntry.Add(subPbe3);
// Create an instance of PdfSaveOptions
Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();
// Set the PDF Bookmark root object
pdfSaveOptions.Bookmark = pbeRoot;
dataDir = dataDir+ "PDFBookmarks_test.out.pdf";
// Save the pdf file
workbook.Save(dataDir, pdfSaveOptions);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = "";
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a Workbook
Workbook workbook = new Workbook();
// Get a reference of comments collection with the first sheet
CommentCollection comments = workbook.Worksheets[0].Comments;
// Add a comment to cell A1
int commentIndex = comments.Add(0, 0);
Comment comment = comments[commentIndex];
comment.Note = "First note.";
comment.Font.Name = "Times New Roman";
// Load an image into stream
Bitmap bmp = new Bitmap(dataDir + "image2.jpg");
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
// Set image data to the shape associated with the comment
comment.CommentShape.Fill.ImageData = ms.ToArray();
dataDir = dataDir + "commentwithpicture1.out.xlsx";
// Save the workbook
workbook.Save(dataDir, Aspose.Cells.SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object
Workbook wb = new Workbook();
// Access first worksheet
Worksheet ws = wb.Worksheets[0];
// Add Word Art Text with Built-in Styles
ws.Shapes.AddWordArt(PresetWordArtStyle.WordArtStyle1, "Aspose File Format APIs", 00, 0, 0, 0, 100, 800);
ws.Shapes.AddWordArt(PresetWordArtStyle.WordArtStyle2, "Aspose File Format APIs", 10, 0, 0, 0, 100, 800);
ws.Shapes.AddWordArt(PresetWordArtStyle.WordArtStyle3, "Aspose File Format APIs", 20, 0, 0, 0, 100, 800);
ws.Shapes.AddWordArt(PresetWordArtStyle.WordArtStyle4, "Aspose File Format APIs", 30, 0, 0, 0, 100, 800);
ws.Shapes.AddWordArt(PresetWordArtStyle.WordArtStyle5, "Aspose File Format APIs", 40, 0, 0, 0, 100, 800);
// Save the workbook in xlsx format
wb.Save(dataDir + "output_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a new Workbook
Workbook workbook = new Workbook();
// Get the first default sheet
Worksheet sheet = workbook.Worksheets[0];
// Add Watermark
Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
"CONFIDENTIAL", "Arial Black", 50, false, true
, 18, 8, 1, 1, 130, 800);
// Get the fill format of the word art
FillFormat wordArtFormat = wordart.Fill;
// Set the transparency
wordArtFormat.Transparency = 0.9;
// Make the line invisible
LineFormat lineFormat = wordart.Line;
dataDir = dataDir + "Watermark_Test.out.xls";
// Save the file
workbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object
Workbook wb = new Workbook();
// Add xml map found inside the sample.xml inside the workbook
wb.Worksheets.XmlMaps.Add(dataDir + "sample.xml");
// Save the workbook in xlsx format
wb.Save(dataDir + "output_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
// Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
// Sets the conditional format range.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
// Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
// Sets the background color.
FormatCondition fc = fcs[conditionIndex];
fc.Style.BackgroundColor = Color.Red;
// Saving the Excel file
workbook.Save(dataDir+ "output.out.xls", SaveFormat.Auto);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
// Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
// Sets the conditional format range.
CellArea ca = new CellArea();
ca = new CellArea();
ca.StartRow = 2;
ca.EndRow = 2;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
// Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType.Expression);
// Sets the background color.
FormatCondition fc = fcs[conditionIndex];
fc.Formula1 = "=IF(SUM(B1:B2)>100,TRUE,FALSE)";
fc.Style.BackgroundColor = Color.Red;
sheet.Cells["B3"].Formula = "=SUM(B1:B2)";
sheet.Cells["C4"].PutValue("If Sum of B1:B2 is greater than 100, B3 will have RED background");
// Saving the Excel file
workbook.Save(dataDir+ "output.out.xls", SaveFormat.Auto);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a new worksheet to the Excel object
workbook.Worksheets.Add();
// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
// Accessing the "A1" cell from the worksheet
Cell cell = worksheet.Cells["A1"];
// Adding some value to the "A1" cell
cell.PutValue("Hello");
// Setting the font Subscript
Style style = cell.GetStyle();
style.Font.IsSubscript = true;
cell.SetStyle(style);
// Saving the Excel file
workbook.Save(dataDir+ "Subscript.out.xls", SaveFormat.Auto);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a new worksheet to the Excel object
workbook.Worksheets.Add();
// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
// Accessing the "A1" cell from the worksheet
Cell cell = worksheet.Cells["A1"];
// Adding some value to the "A1" cell
cell.PutValue("Hello");
// Setting the font Superscript
Style style = cell.GetStyle();
style.Font.IsSuperscript = true;
cell.SetStyle(style);
// Saving the Excel file
workbook.Save(dataDir+ "Superscript.out.xls", SaveFormat.Auto);
//Instantiating an Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet
Worksheet sheet1 = workbook.Worksheets[0];
// Create a range A1:B2
Range range = sheet1.Cells.CreateRange(0, 0, 2, 2);
// Merge the cells
range.Merge();
// Insert value to the merged cell A1
sheet1.Cells[0, 0].Value = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end";
// Create a style object
Style style = sheet1.Cells[0, 0].GetStyle();
// Set wrapping text on
style.IsTextWrapped = true;
// Apply the style to the cell
sheet1.Cells[0, 0].SetStyle(style);
// Create an object for AutoFitterOptions
AutoFitterOptions options = new AutoFitterOptions();
// Only expands the height of the first row.
options.AutoFitMergedCellsType = AutoFitMergedCellsType.FirstLine;
// Autofit rows in the sheet(including the merged cells)
sheet1.AutoFitRows(options);
int index = workbook.Worksheets.Add();
Worksheet sheet2 = workbook.Worksheets[index];
sheet2.Name = "Sheet2";
// Create a range A1:B2
Range range2 = sheet2.Cells.CreateRange(0, 0, 2, 2);
// Merge the cells
range2.Merge();
// Insert value to the merged cell A1
sheet2.Cells[0, 0].Value = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end";
// Create a style object
Style style2 = sheet2.Cells[0, 0].GetStyle();
// Set wrapping text on
style2.IsTextWrapped = true;
// Apply the style to the cell
sheet2.Cells[0, 0].SetStyle(style);
// Create an object for AutoFitterOptions
AutoFitterOptions options2 = new AutoFitterOptions();
// Only expands the height of the last row.
options2.AutoFitMergedCellsType = AutoFitMergedCellsType.LastLine;
// Autofit rows in the sheet(including the merged cells)
sheet2.AutoFitRows(options2);
index = workbook.Worksheets.Add();
Worksheet sheet3 = workbook.Worksheets[index];
sheet3.Name = "Sheet3";
// Create a range A1:B2
Range range3 = sheet3.Cells.CreateRange(0, 0, 2, 2);
// Merge the cells
range3.Merge();
// Insert value to the merged cell A1
sheet3.Cells[0, 0].Value = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end";
// Create a style object
Style style3 = sheet3.Cells[0, 0].GetStyle();
// Set wrapping text on
style3.IsTextWrapped = true;
// Apply the style to the cell
sheet3.Cells[0, 0].SetStyle(style);
// Create an object for AutoFitterOptions
AutoFitterOptions options3 = new AutoFitterOptions();
// Only expands the height of each row.
options3.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine;
// Autofit rows in the sheet(including the merged cells)
sheet3.AutoFitRows(options3);
index = workbook.Worksheets.Add();
Worksheet sheet4 = workbook.Worksheets[index];
sheet4.Name = "Sheet4";
// Create a range A1:B2
Range range4 = sheet4.Cells.CreateRange(0, 0, 2, 2);
// Merge the cells
range4.Merge();
// Insert value to the merged cell A1
sheet4.Cells[0, 0].Value = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end";
// Create a style object
Style style4 = sheet4.Cells[0, 0].GetStyle();
// Set wrapping text on
style4.IsTextWrapped = true;
// Apply the style to the cell
sheet4.Cells[0, 0].SetStyle(style);
// Create an object for AutoFitterOptions
AutoFitterOptions options4 = new AutoFitterOptions();
// Ignore merged cells.
options4.AutoFitMergedCellsType = AutoFitMergedCellsType.None;
// Autofit rows in the sheet(not including the merged cells)
sheet4.AutoFitRows(options4);
// Save the Excel file
workbook.Save("out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Sample Html containing large number with digits greater than 15
string html = "<html><body><p>1234567890123456</p></body></html>";
// Convert Html to byte array
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(html);
// Set Html load options and keep precision true
HtmlLoadOptions loadOptions = new Aspose.Cells.HtmlLoadOptions(LoadFormat.Html);
loadOptions.KeepPrecision = true;
// Convert byte array into stream
MemoryStream stream = new MemoryStream(byteArray);
// Create workbook from stream with Html load options
Workbook workbook = new Workbook(stream, loadOptions);
// Access first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Auto fit the sheet columns
sheet.AutoFitColumns();
// Save the workbook
workbook.Save(outputDir + "outputAvoidExponentialNotationWhileImportingFromHtml.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
// Instantiate a new Workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Add some text in cell A1
worksheet.Cells["A1"].PutValue("Here");
// Add a comment to A1 cell
var comment = worksheet.Comments[worksheet.Comments.Add("A1")];
// Set its vertical alignment setting
comment.CommentShape.TextVerticalAlignment = TextAlignmentType.Center;
// Set the Comment note
comment.Note = "This is my Comment Text. This is Test.";
Shape shape = worksheet.Comments["A1"].CommentShape;
shape.Fill.SolidFill.Color = Color.Black;
Font font = shape.Font;
font.Color = Color.White;
StyleFlag styleFlag = new StyleFlag();
styleFlag.FontColor = true;
shape.TextBody.Format(0, shape.Text.Length, font, styleFlag);
// Save the Excel file
workbook.Save(outputDir + "outputChangeCommentFontColor.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
string inputPath = dataDir + "Sample1.xlsx";
string outputPath = dataDir + "Output.out.html";
Workbook workbook = new Workbook(dataDir + "Sample1.xlsx");
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.LinkTargetType = HtmlLinkTargetType.Self;
workbook.Save(outputPath, opts);
Console.WriteLine("File saved: {0}", outputPath);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
// Load your excel file inside a workbook obect
Workbook wb = new Workbook(sourceDir + "sampleChangeTextBoxOrShapeCharacterSpacing.xlsx");
// Access your text box which is also a shape object from shapes collection
Shape shape = wb.Worksheets[0].Shapes[0];
// Access the first font setting object via GetCharacters() method
FontSetting fs = (FontSetting)shape.GetCharacters()[0];
//Set the character spacing to point 4
fs.TextOptions.Spacing = 4;
// Save the workbook in xlsx format
wb.Save(outputDir + "outputChangeTextBoxOrShapeCharacterSpacing.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a new Workbook
var wb = new Workbook();
// Get the first worksheet
var sheet = wb.Worksheets[0];
// Add a comment to A1 cell
var comment = sheet.Comments[sheet.Comments.Add("A1")];
// Set its vertical alignment setting
comment.CommentShape.TextVerticalAlignment = TextAlignmentType.Center;
// Set its horizontal alignment setting
comment.CommentShape.TextHorizontalAlignment = TextAlignmentType.Right;
// Set the Text Direction - Right-to-Left
comment.CommentShape.TextDirection = TextDirectionType.RightToLeft;
// Set the Comment note
comment.Note = "This is my Comment Text. This is test";
dataDir = dataDir + "OutCommentShape.out.xlsx";
// Save the Excel file
wb.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the template file.
Workbook workbook = new Workbook(dataDir + "Sample.xlsx");
// Access the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Access the first chart inside the sheet
Chart chart = sheet.Charts[0];
// Set text of second legend entry fill to none
chart.Legend.LegendEntries[1].IsTextNoFill = true;
// Save the workbook in xlsx format
workbook.Save(dataDir + "ChartLegendEntry_out.xlsx", SaveFormat.Xlsx);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
Workbook book = new Workbook(sourceDir + "sampleValidation.xlsx");
Worksheet sheet = book.Worksheets["Sheet1"];
Cells cells = sheet.Cells;
Cell a2 = cells["A2"];
Validation va2 = a2.GetValidation();
if (va2.InCellDropDown)
{
Console.WriteLine("A2 is a dropdown");
}
else
{
Console.WriteLine("A2 is NOT a dropdown");
}
Cell b2 = cells["B2"];
Validation vb2 = b2.GetValidation();
if (vb2.InCellDropDown)
{
Console.WriteLine("B2 is a dropdown");
}
else
{
Console.WriteLine("B2 is NOT a dropdown");
}
Cell c2 = cells["C2"];
Validation vc2 = c2.GetValidation();
if (vc2.InCellDropDown)
{
Console.WriteLine("C2 is a dropdown");
}
else
{
Console.WriteLine("C2 is NOT a dropdown");
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Define the first source
// Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");
// Define the second source book.
// Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");
// Combining the two workbooks
SourceBook1.Combine(SourceBook2);
dataDir = dataDir + "Combined.out.xlsx";
// Save the target book file.
SourceBook1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
string filePath = dataDir+ "SampleInput.xlsx";
Workbook workbook = new Workbook(filePath);
Workbook destWorkbook = new Workbook();
Worksheet destSheet = destWorkbook.Worksheets[0];
int TotalRowCount = 0;
for (int i = 0; i < workbook.Worksheets.Count; i++)
{
Worksheet sourceSheet = workbook.Worksheets[i];
Range sourceRange = sourceSheet.Cells.MaxDisplayRange;
Range destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow + TotalRowCount, sourceRange.FirstColumn,
sourceRange.RowCount, sourceRange.ColumnCount);
destRange.Copy(sourceRange);
TotalRowCount = sourceRange.RowCount + TotalRowCount;
}
dataDir = dataDir + "Output.out.xlsx";
destWorkbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
LoadOptions options = new LoadOptions(LoadFormat.Xlsx);
options.CultureInfo = new CultureInfo("ja-JP");
Workbook workbook = new Workbook(sourceDir + "JapaneseDates.xlsx", options);
workbook.Save(outputDir + "JapaneseDates.pdf", SaveFormat.Pdf);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the existing excel file which contains the column chart.
Workbook workbook = new Workbook(dataDir+ "ColumnChart.xlsx");
// Get the designer chart (first chart) in the first worksheet of the workbook.
Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0];
// Convert the chart to an image file.
chart.ToImage(dataDir+ "ColumnChart.out.jpeg", ImageType.Jpeg);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the existing excel file which contains the pie chart.
Workbook workbook = new Workbook(dataDir+ "PieChart.xlsx");
// Get the designer chart (first chart) in the first worksheet of the workbook.
Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0];
// Convert the chart to an image file.
chart.ToImage(dataDir+ "PieChart.out.emf", ImageType.Emf);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
Workbook book = new Workbook(sourceDir + "sampleConvertWorksheetToImageByPage.xlsx");
Worksheet sheet = book.Worksheets[0];
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.HorizontalResolution = 200;
options.VerticalResolution = 200;
options.ImageType = Drawing.ImageType.Tiff;
// Sheet2Image By Page conversion
SheetRender sr = new SheetRender(sheet, options);
for (int j = 0; j < sr.PageCount; j++)
{
sr.ToImage(j, outputDir + "outputConvertWorksheetToImageByPage_" + (j + 1) + ".tif");
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
// Open a template excel file
Workbook book = new Workbook(sourceDir + "sampleConvertWorksheettoImageFile.xlsx");
// Get the first worksheet.
Worksheet sheet = book.Worksheets[0];
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.OnePagePerSheet = true;
// Specify the image format
imgOptions.ImageType = Drawing.ImageType.Jpeg;
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
// Render the image for the sheet
Bitmap bitmap = sr.ToImage(0);
// Save the image file
bitmap.Save(outputDir + "outputConvertWorksheettoImageFile.jpg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
// Instantiate a workbook
var workbook = new Workbook();
// Put sample text in the first cell of first worksheet in the newly created workbook
workbook.Worksheets[0].Cells["A1"].Value = "DEMO TEXT ON SHEET1";
// Add second worksheet in the workbook
workbook.Worksheets.Add(SheetType.Worksheet);
// Set text in first cell of the second sheet
workbook.Worksheets[1].Cells["A1"].Value = "DEMO TEXT ON SHEET2";
// Set currently active sheet incex to 1 i.e. Sheet2
workbook.Worksheets.ActiveSheetIndex = 1;
// Save workbook to SVG. It shall render the active sheet only to SVG
workbook.Save(outputDir + "ConvertWorksheetToSVG_out.svg");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try
{
// Get the template excel file path.
string designerFile = dataDir + "SampleInput.xls";
// Specify the pdf file path.
string pdfFile = dataDir + "Output.out.pdf";
// Open the template excel file
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(designerFile);
// Save the pdf file.
wb.Save(pdfFile, SaveFormat.Pdf);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Get the first Worksheet Cells.
Cells cells = workbook.Worksheets[0].Cells;
// Fill some sample data into the cells.
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 10; j++)
{
cells[i, j].PutValue(i.ToString() + "," + j.ToString());
}
}
// Create a range (A1:D3).
Range range = cells.CreateRange("A1", "D3");
// Create a style object.
Style style;
style = workbook.CreateStyle();
// Specify the font attribute.
style.Font.Name = "Calibri";
// Specify the shading color.
style.ForegroundColor = Color.Yellow;
style.Pattern = BackgroundType.Solid;
// Specify the border attributes.
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.TopBorder].Color = Color.Blue;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.BottomBorder].Color = Color.Blue;
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.LeftBorder].Color = Color.Blue;
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.RightBorder].Color = Color.Blue;
// Create the styleflag object.
StyleFlag flag1 = new StyleFlag();
// Implement font attribute
flag1.FontName = true;
// Implement the shading / fill color.
flag1.CellShading = true;
// Implment border attributes.
flag1.Borders = true;
// Set the Range style.
range.ApplyStyle(style, flag1);
// Create a second range (C10:F12).
Range range2 = cells.CreateRange("C10", "F12");
// Copy the range data only.
range2.CopyData(range);
dataDir = dataDir + "CopyRangeData.out.xlsx";
// Save the excel file.
workbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Get the first Worksheet Cells.
Cells cells = workbook.Worksheets[0].Cells;
// Fill some sample data into the cells.
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 10; j++)
{
cells[i, j].PutValue(i.ToString() + "," + j.ToString());
}
}
// Create a range (A1:D3).
Range range = cells.CreateRange("A1", "D3");
// Create a style object.
Style style;
style = workbook.CreateStyle();
// Specify the font attribute.
style.Font.Name = "Calibri";
// Specify the shading color.
style.ForegroundColor = Color.Yellow;
style.Pattern = BackgroundType.Solid;
// Specify the border attributes.
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.TopBorder].Color = Color.Blue;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.BottomBorder].Color = Color.Blue;
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.LeftBorder].Color = Color.Blue;
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.RightBorder].Color = Color.Blue;
// Create the styleflag object.
StyleFlag flag1 = new StyleFlag();
// Implement font attribute
flag1.FontName = true;
// Implement the shading / fill color.
flag1.CellShading = true;
// Implment border attributes.
flag1.Borders = true;
// Set the Range style.
range.ApplyStyle(style, flag1);
// Create a second range (C10:F12).
Range range2 = cells.CreateRange("C10", "F12");
// Copy the range data with formatting.
range2.Copy(range);
dataDir = dataDir + "CopyRange.out.xlsx";
// Save the excel file.
workbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Get the first Worksheet Cells.
Cells cells = workbook.Worksheets[0].Cells;
// Fill some sample data into the cells.
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 10; j++)
{
cells[i, j].PutValue(i.ToString() + "," + j.ToString());
}
}
// Create a range (A1:D3).
Range range = cells.CreateRange("A1", "D3");
// Create a style object.
Style style;
style = workbook.CreateStyle();
// Specify the font attribute.
style.Font.Name = "Calibri";
// Specify the shading color.
style.ForegroundColor = Color.Yellow;
style.Pattern = BackgroundType.Solid;
// Specify the border attributes.
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.TopBorder].Color = Color.Blue;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.BottomBorder].Color = Color.Blue;
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.LeftBorder].Color = Color.Blue;
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.RightBorder].Color = Color.Blue;
// Create the styleflag object.
StyleFlag flag1 = new StyleFlag();
// Implement font attribute
flag1.FontName = true;
// Implement the shading / fill color.
flag1.CellShading = true;
// Implment border attributes.
flag1.Borders = true;
// Set the Range style.
range.ApplyStyle(style, flag1);
// Create a second range (C10:E13).
Range range2 = cells.CreateRange("C10", "E13");
// Copy the range style only.
range2.CopyStyle(range);
dataDir = dataDir + "copyrangestyle.out.xls";
// Save the excel file.
workbook.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create an instance of Workbook class by loading the existing spreadsheet
Workbook workbook = new Workbook(dataDir + "aspose-sample.xlsx");
// Get the cells collection of worksheet by name Columns
Cells cells = workbook.Worksheets["Columns"].Cells;
// Copy the first 3 columns 7th column
cells.CopyColumns(cells, 0, 6, 3);
// Save the result on disc
workbook.Save(dataDir + "output_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create an instance of Workbook class by loading the existing spreadsheet
Workbook workbook = new Workbook(dataDir + "aspose-sample.xlsx");
// Get the cells collection of worksheet by name Rows
Cells cells = workbook.Worksheets["Rows"].Cells;
// Copy the first 3 rows to 7th row
cells.CopyRows(cells, 0, 6, 3);
// Save the result on disc
workbook.Save(dataDir + "output_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a new Workbook
// Open an existing excel file
Workbook workbook = new Workbook(dataDir+ "aspose-sample.xlsx");
// Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get the Cells collection
Cells cells = worksheet.Cells;
//Copy the first column to next 10 columns
for (int i = 1; i <= 10; i++)
{
cells.CopyColumn(cells, 0, i);
}
// Save the excel file
workbook.Save(dataDir+ "outaspose-sample.out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a new workbook
// Open an existing excel file
Workbook workbook = new Workbook(dataDir+ "aspose-sample.xlsx");
// Get the first worksheet cells
Cells cells = workbook.Worksheets[0].Cells;
//Copy the first row to next 10 rows
for (int i = 1; i <= 10; i++)
{
cells.CopyRow(cells, 0, i);
}
// Save the excel file
workbook.Save(dataDir + "outaspose-sample.out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate the Workbook
// Load an Excel file
Workbook workbook = new Workbook(dataDir+ "aspose-sample.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
if (worksheet.Scenarios.Count > 0)
{
// Remove the existing first scenario from the sheet
worksheet.Scenarios.RemoveAt(0);
// Create a scenario
int i = worksheet.Scenarios.Add("MyScenario");
// Get the scenario
Scenario scenario = worksheet.Scenarios[i];
// Add comment to it
scenario.Comment = "Test sceanrio is created.";
// Get the input cells for the scenario
ScenarioInputCellCollection sic = scenario.InputCells;
// Add the scenario on B4 (as changing cell) with default value
sic.Add(3, 1, "1100000");
dataDir = dataDir + "outBk_scenarios1.out.xlsx";
// Save the Excel file.
workbook.Save(dataDir);
Console.WriteLine("\nProcess completed successfully.\nFile saved at " + dataDir);
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiating an Workbook object
// Opening the excel file
Workbook workbook = new Workbook(dataDir+ "pivotTable_test.xlsx");
// Adding a new sheet
Worksheet sheet3 = workbook.Worksheets[workbook.Worksheets.Add(SheetType.Chart)];
// Naming the sheet
sheet3.Name = "PivotChart";
// Adding a column chart
int index = sheet3.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 0, 5, 28, 16);
// Setting the pivot chart data source
sheet3.Charts[index].PivotSource = "PivotTable!PivotTable1";
sheet3.Charts[index].HidePivotFieldButtons = false;
// Saving the Excel file
workbook.Save(dataDir+ "pivotChart_test_out.xlsx");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiating an Workbook object
Workbook workbook = new Workbook();
// Obtaining the reference of the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Name the sheet
sheet.Name = "Data";
Cells cells = sheet.Cells;
// Setting the values to the cells
Cell cell = cells["A1"];
cell.PutValue("Employee");
cell = cells["B1"];
cell.PutValue("Quarter");
cell = cells["C1"];
cell.PutValue("Product");
cell = cells["D1"];
cell.PutValue("Continent");
cell = cells["E1"];
cell.PutValue("Country");
cell = cells["F1"];
cell.PutValue("Sale");
cell = cells["A2"];
cell.PutValue("David");
cell = cells["A3"];
cell.PutValue("David");
cell = cells["A4"];
cell.PutValue("David");
cell = cells["A5"];
cell.PutValue("David");
cell = cells["A6"];
cell.PutValue("James");
cell = cells["A7"];
cell.PutValue("James");
cell = cells["A8"];
cell.PutValue("James");
cell = cells["A9"];
cell.PutValue("James");
cell = cells["A10"];
cell.PutValue("James");
cell = cells["A11"];
cell.PutValue("Miya");
cell = cells["A12"];
cell.PutValue("Miya");
cell = cells["A13"];
cell.PutValue("Miya");
cell = cells["A14"];
cell.PutValue("Miya");
cell = cells["A15"];
cell.PutValue("Miya");
cell = cells["A16"];
cell.PutValue("Miya");
cell = cells["A17"];
cell.PutValue("Miya");
cell = cells["A18"];
cell.PutValue("Elvis");
cell = cells["A19"];
cell.PutValue("Elvis");
cell = cells["A20"];
cell.PutValue("Elvis");
cell = cells["A21"];
cell.PutValue("Elvis");
cell = cells["A22"];
cell.PutValue("Elvis");
cell = cells["A23"];
cell.PutValue("Elvis");
cell = cells["A24"];
cell.PutValue("Elvis");
cell = cells["A25"];
cell.PutValue("Jean");
cell = cells["A26"];
cell.PutValue("Jean");
cell = cells["A27"];
cell.PutValue("Jean");
cell = cells["A28"];
cell.PutValue("Ada");
cell = cells["A29"];
cell.PutValue("Ada");
cell = cells["A30"];
cell.PutValue("Ada");
cell = cells["B2"];
cell.PutValue("1");
cell = cells["B3"];
cell.PutValue("2");
cell = cells["B4"];
cell.PutValue("3");
cell = cells["B5"];
cell.PutValue("4");
cell = cells["B6"];
cell.PutValue("1");
cell = cells["B7"];
cell.PutValue("2");
cell = cells["B8"];
cell.PutValue("3");
cell = cells["B9"];
cell.PutValue("4");
cell = cells["B10"];
cell.PutValue("4");
cell = cells["B11"];
cell.PutValue("1");
cell = cells["B12"];
cell.PutValue("1");
cell = cells["B13"];
cell.PutValue("2");
cell = cells["B14"];
cell.PutValue("2");
cell = cells["B15"];
cell.PutValue("3");
cell = cells["B16"];
cell.PutValue("4");
cell = cells["B17"];
cell.PutValue("4");
cell = cells["B18"];
cell.PutValue("1");
cell = cells["B19"];
cell.PutValue("1");
cell = cells["B20"];
cell.PutValue("2");
cell = cells["B21"];
cell.PutValue("3");
cell = cells["B22"];
cell.PutValue("3");
cell = cells["B23"];
cell.PutValue("4");
cell = cells["B24"];
cell.PutValue("4");
cell = cells["B25"];
cell.PutValue("1");
cell = cells["B26"];
cell.PutValue("2");
cell = cells["B27"];
cell.PutValue("3");
cell = cells["B28"];
cell.PutValue("1");
cell = cells["B29"];
cell.PutValue("2");
cell = cells["B30"];
cell.PutValue("3");
cell = cells["C2"];
cell.PutValue("Maxilaku");
cell = cells["C3"];
cell.PutValue("Maxilaku");
cell = cells["C4"];
cell.PutValue("Chai");
cell = cells["C5"];
cell.PutValue("Maxilaku");
cell = cells["C6"];
cell.PutValue("Chang");
cell = cells["C7"];
cell.PutValue("Chang");
cell = cells["C8"];
cell.PutValue("Chang");
cell = cells["C9"];
cell.PutValue("Chang");
cell = cells["C10"];
cell.PutValue("Chang");
cell = cells["C11"];
cell.PutValue("Geitost");
cell = cells["C12"];
cell.PutValue("Chai");
cell = cells["C13"];
cell.PutValue("Geitost");
cell = cells["C14"];
cell.PutValue("Geitost");
cell = cells["C15"];
cell.PutValue("Maxilaku");
cell = cells["C16"];
cell.PutValue("Geitost");
cell = cells["C17"];
cell.PutValue("Geitost");
cell = cells["C18"];
cell.PutValue("Ikuru");
cell = cells["C19"];
cell.PutValue("Ikuru");
cell = cells["C20"];
cell.PutValue("Ikuru");
cell = cells["C21"];
cell.PutValue("Ikuru");
cell = cells["C22"];
cell.PutValue("Ipoh Coffee");
cell = cells["C23"];
cell.PutValue("Ipoh Coffee");
cell = cells["C24"];
cell.PutValue("Ipoh Coffee");
cell = cells["C25"];
cell.PutValue("Chocolade");
cell = cells["C26"];
cell.PutValue("Chocolade");
cell = cells["C27"];
cell.PutValue("Chocolade");
cell = cells["C28"];
cell.PutValue("Chocolade");
cell = cells["C29"];
cell.PutValue("Chocolade");
cell = cells["C30"];
cell.PutValue("Chocolade");
cell = cells["D2"];
cell.PutValue("Asia");
cell = cells["D3"];
cell.PutValue("Asia");
cell = cells["D4"];
cell.PutValue("Asia");
cell = cells["D5"];
cell.PutValue("Asia");
cell = cells["D6"];
cell.PutValue("Europe");
cell = cells["D7"];
cell.PutValue("Europe");
cell = cells["D8"];
cell.PutValue("Europe");
cell = cells["D9"];
cell.PutValue("Europe");
cell = cells["D10"];
cell.PutValue("Europe");
cell = cells["D11"];
cell.PutValue("America");
cell = cells["D12"];
cell.PutValue("America");
cell = cells["D13"];
cell.PutValue("America");
cell = cells["D14"];
cell.PutValue("America");
cell = cells["D15"];
cell.PutValue("America");
cell = cells["D16"];
cell.PutValue("America");
cell = cells["D17"];
cell.PutValue("America");
cell = cells["D18"];
cell.PutValue("Europe");
cell = cells["D19"];
cell.PutValue("Europe");
cell = cells["D20"];
cell.PutValue("Europe");
cell = cells["D21"];
cell.PutValue("Oceania");
cell = cells["D22"];
cell.PutValue("Oceania");
cell = cells["D23"];
cell.PutValue("Oceania");
cell = cells["D24"];
cell.PutValue("Oceania");
cell = cells["D25"];
cell.PutValue("Africa");
cell = cells["D26"];
cell.PutValue("Africa");
cell = cells["D27"];
cell.PutValue("Africa");
cell = cells["D28"];
cell.PutValue("Africa");
cell = cells["D29"];
cell.PutValue("Africa");
cell = cells["D30"];
cell.PutValue("Africa");
cell = cells["E2"];
cell.PutValue("China");
cell = cells["E3"];
cell.PutValue("India");
cell = cells["E4"];
cell.PutValue("Korea");
cell = cells["E5"];
cell.PutValue("India");
cell = cells["E6"];
cell.PutValue("France");
cell = cells["E7"];
cell.PutValue("France");
cell = cells["E8"];
cell.PutValue("Germany");
cell = cells["E9"];
cell.PutValue("Italy");
cell = cells["E10"];
cell.PutValue("France");
cell = cells["E11"];
cell.PutValue("U.S.");
cell = cells["E12"];
cell.PutValue("U.S.");
cell = cells["E13"];
cell.PutValue("Brazil");
cell = cells["E14"];
cell.PutValue("U.S.");
cell = cells["E15"];
cell.PutValue("U.S.");
cell = cells["E16"];
cell.PutValue("Canada");
cell = cells["E17"];
cell.PutValue("U.S.");
cell = cells["E18"];
cell.PutValue("Italy");
cell = cells["E19"];
cell.PutValue("France");
cell = cells["E20"];
cell.PutValue("Italy");
cell = cells["E21"];
cell.PutValue("New Zealand");
cell = cells["E22"];
cell.PutValue("Australia");
cell = cells["E23"];
cell.PutValue("Australia");
cell = cells["E24"];
cell.PutValue("New Zealand");
cell = cells["E25"];
cell.PutValue("S.Africa");
cell = cells["E26"];
cell.PutValue("S.Africa");
cell = cells["E27"];
cell.PutValue("S.Africa");
cell = cells["E28"];
cell.PutValue("Egypt");
cell = cells["E29"];
cell.PutValue("Egypt");
cell = cells["E30"];
cell.PutValue("Egypt");
cell = cells["F2"];
cell.PutValue(2000);
cell = cells["F3"];
cell.PutValue(500);
cell = cells["F4"];
cell.PutValue(1200);
cell = cells["F5"];
cell.PutValue(1500);
cell = cells["F6"];
cell.PutValue(500);
cell = cells["F7"];
cell.PutValue(1500);
cell = cells["F8"];
cell.PutValue(800);
cell = cells["F9"];
cell.PutValue(900);
cell = cells["F10"];
cell.PutValue(500);
cell = cells["F11"];
cell.PutValue(1600);
cell = cells["F12"];
cell.PutValue(600);
cell = cells["F13"];
cell.PutValue(2000);
cell = cells["F14"];
cell.PutValue(500);
cell = cells["F15"];
cell.PutValue(900);
cell = cells["F16"];
cell.PutValue(700);
cell = cells["F17"];
cell.PutValue(1400);
cell = cells["F18"];
cell.PutValue(1350);
cell = cells["F19"];
cell.PutValue(300);
cell = cells["F20"];
cell.PutValue(500);
cell = cells["F21"];
cell.PutValue(1000);
cell = cells["F22"];
cell.PutValue(1500);
cell = cells["F23"];
cell.PutValue(1500);
cell = cells["F24"];
cell.PutValue(1600);
cell = cells["F25"];
cell.PutValue(1000);
cell = cells["F26"];
cell.PutValue(1200);
cell = cells["F27"];
cell.PutValue(1300);
cell = cells["F28"];
cell.PutValue(1500);
cell = cells["F29"];
cell.PutValue(1400);
cell = cells["F30"];
cell.PutValue(1000);
// Adding a new sheet
Worksheet sheet2 = workbook.Worksheets[workbook.Worksheets.Add()];
// Naming the sheet
sheet2.Name = "PivotTable";
// Getting the pivottables collection in the sheet
Aspose.Cells.Pivot.PivotTableCollection pivotTables = sheet2.PivotTables;
// Adding a PivotTable to the worksheet
int index = pivotTables.Add("=Data!A1:F30", "B3", "PivotTable1");
// Accessing the instance of the newly added PivotTable
Aspose.Cells.Pivot.PivotTable pivotTable = pivotTables[index];
// Showing the grand totals
pivotTable.RowGrand = true;
pivotTable.ColumnGrand = true;
// Setting the PivotTable report is automatically formatted
pivotTable.IsAutoFormat = true;
// Setting the PivotTable autoformat type.
pivotTable.AutoFormatType = Aspose.Cells.Pivot.PivotTableAutoFormatType.Report6;
// Draging the first field to the row area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, 0);
// Draging the third field to the row area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, 2);
// Draging the second field to the row area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, 1);
// Draging the fourth field to the column area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Column, 3);
// Draging the fifth field to the data area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 5);
// Setting the number format of the first data field
pivotTable.DataFields[0].NumberFormat = "$#,##0.00";
// Saving the Excel file
workbook.Save(dataDir+ "pivotTable_test.out.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment