[C#]
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
//Instantiating a Workbook object and open a stream.
Workbook workbook = new Workbook(fstream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1";
//Filtering columns with specified values
worksheet.AutoFilter.Filter(1, "Bananas");
//Saving the modified Excel file.
workbook.Save("C:\\output.xls");
//Closing the file stream to free all resources
fstream.Close();
[Visual Basic]
'Creating a file stream containing the Excel file to be opened
Dim fstream As FileStream = New FileStream("C:\\book1.xls", FileMode.Open)
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook(fstream)
'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1"
'Filtering columns with specified values
Worksheet.AutoFilter.Filter(1, "Bananas")
'Saving the modified Excel file
workbook.Save("C:\\output.xls")
'Closing the file stream to free all resources
fstream.Close()
[C#]
//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
Aspose.Cells.Cell cell = worksheet.Cells["A1"];
//Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!");
//getting charactor
FontSetting charactor = cell.Characters(6, 7);
//Setting the font of selected characters to bold
charactor.Font.IsBold = true;
//Setting the font color of selected characters to blue
charactor.Font.Color = Color.Blue;
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As 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
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Accessing the "A1" cell from the worksheet
Dim cell As Aspose.Cells.Cell = worksheet.Cells("A1")
'Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!")
'getting charactor
Dim charactor As FontSetting = cell.Characters(6, 7)
'Setting the font of selected characters to bold
charactor.Font.IsBold = True
'Setting the font color of selected characters to blue
charactor.Font.Color = Color.Blue
'Saving the Excel file
workbook.Save("D:\book1.xls")
sheetIndex
later
in startRow(Row) or startCell(Cell) method,
that is, if the process needs to know which worksheet is being processed,
the implementation should retain the sheetIndex
value here.
[C#]
Workbook wb = new Workbook(template, new LoadOptions() { LoadFilter = new LoadFilterSheet() });
//Custom LoadFilter implementation
class LoadFilterSheet : LoadFilter
{
public override void StartSheet(Worksheet sheet)
{
if (sheet.Name == "Sheet1")
{
LoadDataFilterOptions = Aspose.Cells.LoadDataFilterOptions.All;
}
else
{
LoadDataFilterOptions = Aspose.Cells.LoadDataFilterOptions.None;
}
}
}
The following formats are supported: .bmp, .gif, .jpg, .jpeg, .tiff, .emf.
[C#]
//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);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
//Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
//Adds condition.
int conditionIndex2 = 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("C:\\output.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
' Adds an empty conditional formatting
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditionCollection = sheet.ConditionalFormattings(index)
'Sets the conditional format range.
Dim ca As CellArea = New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
ca = New CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.AddArea(ca)
'Adds condition.
Dim conditionIndex As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100")
'Adds condition.
Dim conditionIndex2 As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100")
'Sets the background color.
Dim fc As FormatCondition = fcs(conditionIndex)
fc.Style.BackgroundColor = Color.Red
'Saving the Excel file
workbook.Save("C:\output.xls")
[C#]
Workbook workbook = new Workbook();
workbook.Worksheets.Add();
workbook.Worksheets.Add();
Cell cellInPage1 = workbook.Worksheets[0].Cells["A0"];
Cell cellInPage2 = workbook.Worksheets[1].Cells["A0"];
Cell cellInPage3 = workbook.Worksheets[2].Cells["A0"];
cellInPage1.PutValue("page1");
cellInPage2.PutValue("page2");
cellInPage3.PutValue("page3");
PdfBookmarkEntry pbeRoot = new PdfBookmarkEntry();
pbeRoot.Text = "root"; // if pbeRoot.Text = null, all children of pbeRoot will be inserted on the top level in the bookmark.
pbeRoot.Destination = cellInPage1;
pbeRoot.SubEntry = new ArrayList();
pbeRoot.IsOpen = false;
PdfBookmarkEntry subPbe1 = new PdfBookmarkEntry();
subPbe1.Text = "section1";
subPbe1.Destination = cellInPage2;
PdfBookmarkEntry subPbe2 = new PdfBookmarkEntry();
subPbe2.Text = "section2";
subPbe2.Destination = cellInPage3;
pbeRoot.SubEntry.Add(subPbe1);
pbeRoot.SubEntry.Add(subPbe2);
workbook.SaveOptions.PdfBookmark = pbeRoot;
workbook.Save("c:\\Test.pdf");
[VB]
Dim workbook As Workbook = New Workbook
workbook.Worksheets.Add("sheet2")
workbook.Worksheets.Add("sheet3")
Dim cells As Cells = workbook.Worksheets(0).Cells
Dim cellInPage1 As Cell = cells("A0")
cellInPage1.PutValue("Page1")
cells = workbook.Worksheets(1).Cells
Dim cellInPage2 As Cell = cells("A0")
cellInPage2.PutValue("Page2")
cells = workbook.Worksheets(2).Cells
Dim cellInPage3 As Cell = cells("A0")
cellInPage3.PutValue("Page3")
Dim pbeRoot As PdfBookmarkEntry = New PdfBookmarkEntry()
pbeRoot.Text = "root"
pbeRoot.Destination = cellInPage1
pbeRoot.SubEntry = New ArrayList
pbeRoot.IsOpen = False
Dim subPbe1 As PdfBookmarkEntry = New PdfBookmarkEntry()
subPbe1.Text = "section1"
subPbe1.Destination = cellInPage2
Dim subPbe2 As PdfBookmarkEntry = New PdfBookmarkEntry()
subPbe2.Text = "section2"
subPbe2.Destination = cellInPage3
pbeRoot.SubEntry.Add(subPbe1)
pbeRoot.SubEntry.Add(subPbe2)
workbook.SaveOptions.PdfBookmark = pbeRoot
workbook.Save("c:\\Test.pdf")
[C#]
public class MyEngine : AbstractCalculationEngine
{
public override void Calculate(CalculationData data)
{
string funcName = data.FunctionName.ToUpper();
if ("MYFUNC".Equals(funcName))
{
//do calculation for MYFUNC here
int count = data.ParamCount;
object res = null;
for (int i = 0; i < count; i++)
{
object pv = data.GetParamValue(i);
if (pv is ReferredArea)
{
ReferredArea ra = (ReferredArea)pv;
pv = ra.GetValue(0, 0);
}
//process the parameter here
//res = ...;
}
data.CalculatedValue = res;
}
}
}
[C#]
//Filling the area of the 2nd NSeries with a gradient
chart.NSeries[1].Area.FillFormat.SetOneColorGradient(Color.Lime, 1, GradientStyleType.Horizontal, 1);
[Visual Basic]
'Filling the area of the 2nd NSeries with a gradient
chart.NSeries(1).Area.FillFormat.SetOneColorGradient(Color.Lime, 1, GradientStyleType.Horizontal, 1)
[C#]
//Custom monitor to check possibility of StackOverflowException
public class MyCalculationMonitor : AbstractCalculationMonitor
{
public override void BeforeCalculate(int sheetIndex, int rowIndex, int colIndex)
{
if(new StackTrace(false).FrameCount > 1000)
{
throw new Exception("Stop the formula calculation because risk of StackOverflowException");
}
}
}
[C#]
Workbook excel = new Workbook();
Cells cells = excel.Worksheets[0].Cells;
//Put a string into a cell
Cell cell = cells[0, 0];
cell.PutValue("Hello");
string first = cell.StringValue;
//Put an integer into a cell
cell = cells["B1"];
cell.PutValue(12);
int second = cell.IntValue;
//Put a double into a cell
cell = cells[0, 2];
cell.PutValue(-1.234);
double third = cell.DoubleValue;
//Put a formula into a cell
cell = cells["D1"];
cell.Formula = "=B1 + C1";
//Put a combined formula: "sum(average(b1,c1), b1)" to cell at b2
cell = cells["b2"];
cell.Formula = "=sum(average(b1,c1), b1)";
//Set style of a cell
Style style = cell.GetStyle();
//Set background color
style.BackgroundColor = Color.Yellow;
//Set format of a cell
style.Font.Name = "Courier New";
style.VerticalAlignment = TextAlignmentType.Top;
cell.SetStyle(style);
[Visual Basic]
Dim excel as Workbook = new Workbook()
Dim cells as Cells = exce.Worksheets(0).Cells
'Put a string into a cell
Dim cell as Cell = cells(0, 0)
cell.PutValue("Hello")
Dim first as String = cell.StringValue
//Put an integer into a cell
cell = cells("B1")
cell.PutValue(12)
Dim second as Integer = cell.IntValue
//Put a double into a cell
cell = cells(0, 2)
cell.PutValue(-1.234)
Dim third as Double = cell.DoubleValue
//Put a formula into a cell
cell = cells("D1")
cell.Formula = "=B1 + C1"
//Put a combined formula: "sum(average(b1,c1), b1)" to cell at b2
cell = cells("b2")
cell.Formula = "=sum(average(b1,c1), b1)"
//Set style of a cell
Dim style as Style = cell.GetStyle()
//Set background color
style.BackgroundColor = Color.Yellow
//Set font of a cell
style.Font.Name = "Courier New"
style.VerticalAlignment = TextAlignmentType.Top
cell.SetStyle(style)
[C#]
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["A1"].Formula = "= B1 + SUM(B1:B10) + [Book1.xls]Sheet1!A1";
ReferredAreas areas = cells["A1"].GetPrecedents();
for (int i = 0; i < areas.Count; i++)
{
ReferredArea area = areas[i];
StringBuilder stringBuilder = new StringBuilder();
if (area.IsExternalLink)
{
stringBuilder.Append("[");
stringBuilder.Append(area.ExternalFileName);
stringBuilder.Append("]");
}
stringBuilder.Append(area.SheetName);
stringBuilder.Append("!");
stringBuilder.Append(CellsHelper.CellIndexToName(area.StartRow, area.StartColumn));
if (area.IsArea)
{
stringBuilder.Append(":");
stringBuilder.Append(CellsHelper.CellIndexToName(area.EndRow, area.EndColumn));
}
Console.WriteLine(stringBuilder.ToString());
}
workbook.Save(@"C:\Book2.xls");
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
cells("A1").Formula = "= B1 + SUM(B1:B10) + [Book1.xls]Sheet1!A1"
Dim areas As ReferredAreas = cells("A1").GetPrecedents()
For i As Integer = 0 To areas.Count - 1
Dim area As ReferredArea = areas(i)
Dim stringBuilder As StringBuilder = New StringBuilder()
If (area.IsExternalLink) Then
stringBuilder.Append("[")
stringBuilder.Append(area.ExternalFileName)
stringBuilder.Append("]")
End If
stringBuilder.Append(area.SheetName)
stringBuilder.Append("!")
stringBuilder.Append(CellsHelper.CellIndexToName(area.StartRow, area.StartColumn))
If (area.IsArea) Then
stringBuilder.Append(":")
stringBuilder.Append(CellsHelper.CellIndexToName(area.EndRow, area.EndColumn))
End If
Console.WriteLine(stringBuilder.ToString())
Next
workbook.Save("C:\Book2.xls")
[C#]
cells["h11"].SetAddInFormula("HRVSTTRK.xla", "=pct_overcut(F3:G3)");
cells["h12"].SetAddInFormula("HRVSTTRK.xla", "=pct_overcut()");
[Visual Basic]
cells("h11").SetAddInFormula("HRVSTTRK.xla", "=pct_overcut(F3:G3)")
cells("h12").SetAddInFormula("HRVSTTRK.xla", "=pct_overcut()")
[C#]
excel.Worksheets[0].Cells["A1"].PutValue("Helloworld");
excel.Worksheets[0].Cells["A1"].Characters(5, 5).Font.IsBold = true;
excel.Worksheets[0].Cells["A1"].Characters(5, 5).Font.Color = Color.Blue;
[Visual Basic]
excel.Worksheets(0).Cells("A1").PutValue("Helloworld")
excel.Worksheets(0).Cells("A1").Characters(5, 5).Font.IsBold = True
excel.Worksheets(0).Cells("A1").Characters(5, 5).Font.Color = Color.Blue
[C#]
Workbook excel = new Workbook();
Cells cells = excel.Worksheets[0];
cells["B6"].Formula = "=SUM(B2:B5, E1) + sheet1!A1";
[Visual Basic]
Dim excel As Workbook = New Workbook()
Dim cells As Cells = excel.Worksheets(0)
cells("B6").Formula = "=SUM(B2:B5, E1) + sheet1!A1"
null,
Boolean,
DateTime,
Double,
Integer
String.
For int value, it may be returned as an Integer object or a Double object. And there is no guarantee that the returned value will be kept as the same type of object always.
[C#]
Workbook excel = new Workbook();
Cells cells = excel.Worksheets[0].Cells;
//Set default row height
cells.StandardHeight = 20;
//Set row height
cells.SetRowHeight(2, 20.5);
//Set default colum width
cells.StandardWidth = 15;
//Set column width
cells.SetColumnWidth(3, 12.57);
//Merge cells
cells.Merge(5, 4, 2, 2);
//Import data
DataTable dt = new DataTable("Products");
dt.Columns.Add("Product_ID",typeof(Int32));
dt.Columns.Add("Product_Name",typeof(string));
dt.Columns.Add("Units_In_Stock",typeof(Int32));
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "Aniseed Syrup";
dr[2] = 15;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Boston Crab Meat";
dr[2] = 123;
dt.Rows.Add(dr);
cells.ImportDataTable(dt, true, 12, 12, 10, 10);
//Export data
DataTable outDataTable = cells.ExportDataTable(12, 12, 10, 10);
[Visual Basic]
Dim excel as Workbook = new Workbook()
Dim cells as Cells = excel.Worksheets(0).Cells
'Set default row height
cells.StandardHeight = 20
'Set row height
cells.SetRowHeight(2, 20.5)
'Set default colum width
cells.StandardWidth = 15
'Set column width
cells.SetColumnWidth(3, 12.57)
'Merge cells
cells.Merge(5, 4, 2, 2)
'Import data
Dim dt as DataTable = new DataTable("Employee")
dt.Columns.Add("Employee_ID",typeof(Int32))
dt.Columns.Add("Employee_Name",typeof(string))
dt.Columns.Add("Gender",typeof(string))
Dim dr as DataRow = dt.NewRow()
dr(0) = 1
dr(1) = "John Smith"
dr(2) = "Male"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 2
dr(1) = "Mary Miller"
dr(2) = "Female"
dt.Rows.Add(dr)
cells.ImportDataTable(dt, true, 12, 12, 10, 10)
'Export data
Dim outDataTable as DataTable = cells.ExportDataTable(12, 12, 10, 10)
[C#]
string designerFile = MapPath("Designer") + "\\List.xls";
Workbook excel = new Workbook(designerFile);
Worksheet sheet = excel.Worksheets[0];
DataTable dt = sheet.Cells.ExportDataTable(6, 1, 69, 4);
this.DataGrid1.DataSource = dt;
this.DataGrid1.DataBind();
[Visual Basic]
Dim designerFile As String = MapPath("Designer") + "\List.xls"
Dim excel As excel = New excel(designerFile)
Dim sheet As Worksheet = excel.Worksheets(0)
Dim dt As DataTable = sheet.Cells.ExportDataTable(6, 1, 69, 4)
Me.DataGrid1.DataSource = dt
Me.DataGrid1.DataBind()
[C#]
DataTable dt = new DataTable("Employee");
dt.Columns.Add("Employee_ID",typeof(Int32));
dt.Columns.Add("Employee_Name",typeof(string));
dt.Columns.Add("Gender",typeof(string));
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "John Smith";
dr[2] = "Male";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Mary Miller";
dr[2] = "Female";
dt.Rows.Add(dr);
cells.ImportDataTable(dt, true, 12, 12, 10, 10);
[Visual Basic]
Dim dt As DataTable = New DataTable("Employee")
dt.Columns.Add("Employee_ID",Type.GetType(Int32))
dt.Columns.Add("Employee_Name",Type.GetType(String))
dt.Columns.Add("Gender",Type.GetType(String))
Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dr(1) = "John Smith"
dr(2) = "Male"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 2
dr(1) = "Mary Miller"
dr(2) = "Female"
dt.Rows.Add(dr)
cells.ImportDataTable(dt, True, 12, 12, 10, 10)
[C#]
Cells cells = excel.Worksheets[0].Cells;
Cell cell = cells[0, 0]; //Gets the cell at "A1"
[Visual Basic]
Dim cells As Cells = excel.Worksheets(0).Cells
Dim cell As Cell = cells(0,0) 'Gets the cell at "A1"
[C#]
Cells cells = excel.Worksheets[0].Cells;
Cell cell = cells["A1"]; //Gets the cell at "A1"
[Visual Basic]
Dim cells As Cells = excel.Worksheets(0).Cells
Dim cell As Cell = cells("A1") 'Gets the cell at "A1"
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Add new Style to Workbook
Style style = workbook.CreateStyle();
//Setting the background color to Blue
style.ForegroundColor = Color.Blue;
//setting Background Pattern
style.Pattern = BackgroundType.Solid;
//New Style Flag
StyleFlag styleFlag = new StyleFlag();
//Set All Styles
styleFlag.All = true;
//Change the default width of first ten columns
for (int i = 0; i < 10; i++)
{
worksheet.Cells.Columns[i].Width = 20;
}
//Get the Column with non default formatting
ColumnCollection columns = worksheet.Cells.Columns;
foreach (Column column in columns)
{
//Apply Style to first ten Columns
column.ApplyStyle(style, styleFlag);
}
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Add new Style to Workbook
Dim style As Style = workbook.CreateStyles()
'Setting the background color to Blue
style.ForegroundColor = Color.Blue
'setting Background Pattern
style.Pattern = BackgroundType.Solid
'New Style Flag
Dim styleFlag As New StyleFlag()
'Set All Styles
styleFlag.All = True
'Change the default width of first ten columns
For i As Integer = 0 To 9
worksheet.Cells.Columns(i).Width = 20
Next i
'Get the Column with non default formatting
Dim columns As ColumnCollection = worksheet.Cells.Columns
For Each column As Column In columns
'Apply Style to first ten Columns
column.ApplyStyle(style, styleFlag)
Next column
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
Style style = workbook.CreateStyle();
//Setting the background color to Blue
style.BackgroundColor = Color.Blue;
//Setting the foreground color to Red
style.ForegroundColor= Color.Red;
//setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe;
//New Style Flag
StyleFlag styleFlag = new StyleFlag();
//Set All Styles
styleFlag.All = true;
//Get first Column
Column column = worksheet.Cells.Columns[0];
//Apply Style to first Column
column.ApplyStyle(style, styleFlag);
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim style As Style = workbook.CreateStyle()
'Setting the background color to Blue
style.BackgroundColor = Color.Blue
'Setting the foreground color to Red
style.ForegroundColor = Color.Red
'setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe
'New Style Flag
Dim styleFlag As New StyleFlag()
'Set All Styles
styleFlag.All = True
'Get first Column
Dim column As Column = worksheet.Cells.Columns(0)
'Apply Style to first Column
column.ApplyStyle(style, styleFlag)
'Saving the Excel file
workbook.Save("D:\book1.xls")
range.Name = "Sheet1!MyRange";
range.Name = "Sheet1!MyRange";
[C#]
//Open a designer file
string designerFile = MapPath("Designer") + "\\designer.xls";
Workbook workbook = new Workbook(designerFile);
//Set scroll bars
workbook.Settings.IsHScrollBarVisible = false;
workbook.Settings.IsVScrollBarVisible = false;
//Replace the placeholder string with new values
int newInt = 100;
workbook.Replace("OldInt", newInt);
string newString = "Hello!";
workbook.Replace("OldString", newString);
XlsSaveOptions saveOptions = new XlsSaveOptions();
workbook.Save(Response, "result.xls", ContentDisposition.Inline, saveOptions);
[Visual Basic]
'Open a designer file
Dim designerFile as String = MapPath("Designer") + "\designer.xls"
Dim workbook as Workbook = new Workbook(designerFile)
'Set scroll bars
workbook.IsHScrollBarVisible = False
workbook.IsVScrollBarVisible = False
'Replace the placeholder string with new values
Dim newInt as Integer = 100
workbook.Replace("OldInt", newInt)
Dim newString as String = "Hello!"
workbook.Replace("OldString", newString)
Dim saveOptions as XlsSaveOptions = new XlsSaveOptions()
workbook.Save(Response, "result.xls", ContentDisposition.Inline, saveOptions)
[C#]
Workbook workbook = new Workbook();
[Visual Basic]
Dim workbook as Workbook = new Workbook()
[C#]
Workbook workbook = new Workbook(FileFormatType.Excel2007Xlsx);
[Visual Basic]
Dim workbook as Workbook = new Workbook(FileFormatType.Excel2007Xlsx)
[C#]
Workbook workbook = new Workbook();
......
workbook.Replace("AnOldValue", "NewValue");
[Visual Basic]
Dim workbook As Workbook = New Workbook()
........
workbook.Replace("AnOldValue", "NewValue")
[C#]
Workbook workbook = new Workbook();
......
int newValue = 100;
workbook.Replace("AnOldValue", newValue);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
.........
Dim NewValue As Integer = 100
workbook.Replace("AnOldValue", NewValue)
[C#]
Workbook workbook = new Workbook();
......
double newValue = 100.0;
workbook.Replace("AnOldValue", newValue);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
.........
Dim NewValue As Double = 100.0
workbook.Replace("AnOldValue", NewValue)
[C#]
Workbook workbook = new Workbook();
......
string[] newValues = new string[]{"Tom", "Alice", "Jerry"};
workbook.Replace("AnOldValue", newValues, true);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
.............
Dim NewValues() As String = New String() {"Tom", "Alice", "Jerry"}
workbook.Replace("AnOldValue", NewValues, True)
[C#]
Workbook workbook = new Workbook();
......
int[] newValues = new int[]{1, 2, 3};
workbook.Replace("AnOldValue", newValues, true);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
...........
Dim NewValues() As Integer = New Integer() {1, 2, 3}
workbook.Replace("AnOldValue", NewValues, True)
[C#]
Workbook workbook = new Workbook();
......
double[] newValues = new double[]{1.23, 2.56, 3.14159};
workbook.Replace("AnOldValue", newValues, true);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
...........
Dim NewValues() As Double = New Double() {1.23, 2.56, 3.14159}
workbook.Replace("AnOldValue", NewValues, True)
[C#]
Workbook workbook = new Workbook();
DataTable myDataTable = new DataTable("Customers");
// Adds data to myDataTable
........
workbook.Replace("AnOldValue", myDataTable);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim myDataTable As DataTable = New DataTable("Customers")
' Adds data to myDataTable
.............
workbook.Replace("AnOldValue", myDataTable)
The following is the standard color palette.
Color¡¡ | Red¡¡ | Green¡¡ | Blue¡¡ |
Black¡¡ | 0¡¡ | 0¡¡ | 0¡¡ |
White¡¡ | 255¡¡ | 255¡¡ | 255¡¡ |
Red¡¡ | 255¡¡ | 0¡¡ | 0¡¡ |
Lime¡¡ | 0¡¡ | 255¡¡ | 0¡¡ |
Blue¡¡ | 0¡¡ | 0¡¡ | 255¡¡ |
Yellow¡¡ | 255¡¡ | 255¡¡ | 0¡¡ |
Magenta¡¡ | 255¡¡ | 0¡¡ | 255¡¡ |
Cyan¡¡ | 0¡¡ | 255¡¡ | 255¡¡ |
Maroon¡¡ | 128¡¡ | 0¡¡ | 0¡¡ |
Green¡¡ | 0¡¡ | 128¡¡ | 0¡¡ |
Navy¡¡ | 0¡¡ | 0¡¡ | 128¡¡ |
Olive¡¡ | 128¡¡ | 128¡¡ | 0¡¡ |
Purple¡¡ | 128¡¡ | 0¡¡ | 128¡¡ |
Teal¡¡ | 0¡¡ | 128¡¡ | 128¡¡ |
Silver¡¡ | 192¡¡ | 192¡¡ | 192¡¡ |
Gray¡¡ | 128¡¡ | 128¡¡ | 128¡¡ |
Color17¡¡ | 153¡¡ | 153¡¡ | 255¡¡ |
Color18¡¡ | 153¡¡ | 51¡¡ | 102¡¡ |
Color19¡¡ | 255¡¡ | 255¡¡ | 204¡¡ |
Color20¡¡ | 204¡¡ | 255¡¡ | 255¡¡ |
Color21¡¡ | 102¡¡ | 0¡¡ | 102¡¡ |
Color22¡¡ | 255¡¡ | 128¡¡ | 128¡¡ |
Color23¡¡ | 0¡¡ | 102¡¡ | 204¡¡ |
Color24¡¡ | 204¡¡ | 204¡¡ | 255¡¡ |
Color25¡¡ | 0¡¡ | 0¡¡ | 128¡¡ |
Color26¡¡ | 255¡¡ | 0¡¡ | 255¡¡ |
Color27¡¡ | 255¡¡ | 255¡¡ | 0¡¡ |
Color28¡¡ | 0¡¡ | 255¡¡ | 255¡¡ |
Color29¡¡ | 128¡¡ | 0¡¡ | 128¡¡ |
Color30¡¡ | 128¡¡ | 0¡¡ | 0¡¡ |
Color31¡¡ | 0¡¡ | 128¡¡ | 128¡¡ |
Color32¡¡ | 0¡¡ | 0¡¡ | 255¡¡ |
Color33¡¡ | 0¡¡ | 204¡¡ | 255¡¡ |
Color34¡¡ | 204¡¡ | 255¡¡ | 255¡¡ |
Color35¡¡ | 204¡¡ | 255¡¡ | 204¡¡ |
Color36¡¡ | 255¡¡ | 255¡¡ | 153¡¡ |
Color37¡¡ | 153¡¡ | 204¡¡ | 255¡¡ |
Color38¡¡ | 255¡¡ | 153¡¡ | 204¡¡ |
Color39¡¡ | 204¡¡ | 153¡¡ | 255¡¡ |
Color40¡¡ | 255¡¡ | 204¡¡ | 153¡¡ |
Color41¡¡ | 51¡¡ | 102¡¡ | 255¡¡ |
Color42¡¡ | 51¡¡ | 204¡¡ | 204¡¡ |
Color43¡¡ | 153¡¡ | 204¡¡ | 0¡¡ |
Color44¡¡ | 255¡¡ | 204¡¡ | 0¡¡ |
Color45¡¡ | 255¡¡ | 153¡¡ | 0¡¡ |
Color46¡¡ | 255¡¡ | 102¡¡ | 0¡¡ |
Color47¡¡ | 102¡¡ | 102¡¡ | 153¡¡ |
Color48¡¡ | 150¡¡ | 150¡¡ | 150¡¡ |
Color49¡¡ | 0¡¡ | 51¡¡ | 102¡¡ |
Color50¡¡ | 51¡¡ | 153¡¡ | 102¡¡ |
Color51¡¡ | 0¡¡ | 51¡¡ | 0¡¡ |
Color52¡¡ | 51¡¡ | 51¡¡ | 0¡¡ |
Color53¡¡ | 153¡¡ | 51¡¡ | 0¡¡ |
Color54¡¡ | 153¡¡ | 51¡¡ | 102¡¡ |
Color55¡¡ | 51¡¡ | 51¡¡ | 153¡¡ |
Color56¡¡ | 51¡¡ | 51¡¡ | 51¡¡ |
Array index¡¡ | Theme type¡¡ |
0¡¡ | Backgournd1¡¡ |
1¡¡ | Text1¡¡ |
2¡¡ | Backgournd2¡¡ |
3¡¡ | Text2¡¡ |
4¡¡ | Accent1¡¡ |
5¡¡ | Accent2¡¡ |
6¡¡ | Accent3¡¡ |
7¡¡ | Accent4¡¡ |
8¡¡ | Accent5¡¡ |
9¡¡ | Accent6¡¡ |
10¡¡ | Hyperlink¡¡ |
11¡¡ | Followed Hyperlink¡¡ |
[C#]
Workbook workbook = new Workbook();
Style defaultStyle = workbook.DefaultStyle;
defaultStyle.Font.Name = "Tahoma";
workbook.DefaultStyle = defaultStyle;
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim defaultStyle as Style = workbook.DefaultStyle
defaultStyle.Font.Name = "Tahoma"
workbook.DefaultStyle = defaultStyle
Title
Subject
Author
Keywords
Comments
Template
Last Author
Revision Number
Application Name
Last Print Date
Creation Date
Last Save Time
Total Editing Time
Number of Pages
Number of Words
Number of Characters
Security
Category
Format
Manager
Company
Number of Bytes
Number of Lines
Number of Paragraphs
Number of Slides
Number of Notes
Number of Hidden Slides
Number of Multimedia Clips
[C#]
DocumentProperty doc = workbook.BuiltInDocumentProperties["Author"];
doc.Value = "John Smith";
[Visual Basic]
Dim doc as DocumentProperty = workbook.BuiltInDocumentProperties("Author")
doc.Value = "John Smith"
[C#]
excel.CustomDocumentProperties.Add("Checked by", "Jane");
[Visual Basic]
excel.CustomDocumentProperties.Add("Checked by", "Jane")
[C#]
// Hide the spreadsheet tabs.
workbook.ShowTabs = false;
[Visual Basic]
' Hide the spreadsheet tabs.
workbook.ShowTabs = False
[C#]
// Hide the horizontal scroll bar of the Excel file.
workbook.IsHScrollBarVisible = false;
[Visual Basic]
' Hide the horizontal scroll bar of the Excel file.
workbook.IsHScrollBarVisible = False
[C#]
// Hide the vertical scroll bar of the Excel file.
workbook.IsVScrollBarVisible = false;
[Visual Basic]
' Hide the vertical scroll bar of the Excel file.
workbook.IsVScrollBarVisible = False
[C#]
Workbook workbook = new Workbook();
WorksheetCollection sheets = workbook.Worksheets;
//Add a worksheet
sheets.Add();
//Change the name of a worksheet
sheets[0].Name = "First Sheet";
//Set the active sheet to the second worksheet
sheets.SetActiveSheet(1);
[Visual Basic]
Dim excel as Workbook = new Workbook()
Dim sheets as WorksheetCollection = excel.Worksheets
'Add a worksheet
sheets.Add()
'Change the name of a worksheet
sheets(0).Name = "First Sheet"
'Set the active sheet to the second worksheet
sheets.SetActiveSheet(1)
[C#]
Workbook workbook = new Workbook();
workbook.Worksheets.Add(SheetType.Chart);
Cells cells = workbook.Worksheets[0].Cells;
cells["c2"].PutValue(5000);
cells["c3"].PutValue(3000);
cells["c4"].PutValue(4000);
cells["c5"].PutValue(5000);
cells["c6"].PutValue(6000);
Charts charts = workbook.Worksheets[1].Charts;
int chartIndex = charts.Add(ChartType.Column, 10,10,20,20);
Chart chart = charts[chartIndex];
chart.NSeries.Add("Sheet1!C2:C6", true);
[Visual Basic]
Dim workbook As Workbook = New Workbook()
workbook.Worksheets.Add(SheetType.Chart)
Dim cells As Cells = workbook.Worksheets(0).Cells
cells("c2").PutValue(5000)
cells("c3").PutValue(3000)
cells("c4").PutValue(4000)
cells("c5").PutValue(5000)
cells("c6").PutValue(6000)
Dim charts As Charts = workbook.Worksheets(1).Charts
Dim chartIndex As Integer = charts.Add(ChartType.Column,10,10,20,20)
Dim chart As Chart = charts(chartIndex)
chart.NSeries.Add("Sheet1!C2:C6", True)
Title
Subject
Author
Keywords
Comments
Template
Last Author
Revision Number
Application Name
Last Print Date
Creation Date
Last Save Time
Total Editing Time
Number of Pages
Number of Words
Number of Characters
Security
Category
Format
Manager
Company
Number of Bytes
Number of Lines
Number of Paragraphs
Number of Slides
Number of Notes
Number of Hidden Slides
Number of Multimedia Clips
[C#]
DocumentProperty doc = workbook.Worksheets.BuiltInDocumentProperties["Author"];
doc.Value = "John Smith";
[Visual Basic]
Dim doc as DocumentProperty = workbook.Worksheets.BuiltInDocumentProperties("Author")
doc.Value = "John Smith"
[C#]
excel.Worksheets.CustomDocumentProperties.Add("Checked by", "Jane");
[Visual Basic]
excel.Worksheets.CustomDocumentProperties.Add("Checked by", "Jane")
[C#]
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Freeze panes at "AS40" with 10 rows and 10 columns
sheet.FreezePanes("AS40", 10, 10);
//Add a hyperlink in Cell A1
sheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim sheet as Worksheet = workbook.Worksheets(0)
'Freeze panes at "AS40" with 10 rows and 10 columns
sheet.FreezePanes("AS40", 10, 10)
'Add a hyperlink in Cell A1
sheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com")
Row index and column index cannot all be zero. Number of rows and number of columns also cannot all be zero.
The first two parameters specify the froze position and the last two parameters specify the area frozen on the left top pane.
[C#]
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
//Instantiating a Workbook object and Opening the Excel file through the file stream
Workbook excel = new Workbook(fstream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = excel.Worksheets[0];
//Protecting the worksheet with a password
worksheet.Protect(ProtectionType.All, "aspose", null);
//Saving the modified Excel file in default (that is Excel 20003) format
excel.Save("C:\\output.xls");
//Closing the file stream to free all resources
fstream.Close();
[Visual Basic]
'Creating a file stream containing the Excel file to be opened
Dim fstream As FileStream = New FileStream("C:\\book1.xls", FileMode.Open)
'Instantiating a Workbook object and Opening the Excel file through the file stream
Dim excel As Workbook = New Workbook(fstream)
'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = excel.Worksheets(0)
'Protecting the worksheet with a password
worksheet.Protect(ProtectionType.All, "aspose", DBNull.Value.ToString())
'Saving the modified Excel file in default (that is Excel 20003) format
excel.Save("C:\\output.xls")
'Closing the file stream to free all resources
fstream.Close()
[C#]
Metered matered = new Metered();
matered.SetMeteredKey("PublicKey", "PrivateKey");
[Visual Basic]
Dim matered As Metered = New Metered
matered.SetMeteredKey("PublicKey", "PrivateKey")
[C#]
sheet.PageSetup.PrintArea = "D1:K13";
sheet.PageSetup.PrintTitleRows = "$5:$7";
sheet.PageSetup.PrintTitleColumns = "$A:$B";
[Visual Basic]
sheet.PageSetup.PrintArea = "D1:K13"
sheet.PageSetup.PrintTitleRows = "$5:$7"
sheet.PageSetup.PrintTitleColumns = "$A:$B"
0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
Header format script.Script commands:
Command ¡¡ | Description ¡¡ |
&P | Current page number¡¡ |
&N | Page count¡¡ |
&D | Current date¡¡ |
&T | Current time |
&A | Sheet name |
&F | File name without path |
&"<FontName>" | Font name, for example: &"Arial" |
&"<FontName>, <FontStyle>" | Font name and font style, for example: &"Arial,Bold" |
&<FontSize> | Font size. If this command is followed by a plain number to be printed in the header, it will be separated from the font height with a space character. |
&"<K" | Font color, for example(RED): &FF0000 |
&G | Image script |
0:Left Section.
1:Center Section
2:Right Section
dddd Footer format script.Script commands:
Command¡¡ | Description¡¡ |
&P | Current page number¡¡ |
&N | Page count¡¡ |
&D | Current date¡¡ |
&T | Current time |
&A | Sheet name |
&F | File name without path |
&"<FontName>" | Font name, for example: &"Arial" |
&"<FontName>, <FontStyle>" | Font name and font style, for example: &"Arial,Bold" |
&<FontSize> | Font size. If this command is followed by a plain number to be printed in the header, it will be separated from the font height with a space character. |
&G | Image script |
0:Left Section.
1:Center Section
2:Right Section
Header format script.0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
Footer format script.0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
Header format script.0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
Footer format script.0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
Image data.0:Left Section.
1:Center Section
2:Right Section
Image data.0:Left Section.
1:Center Section
2:Right Section
Image data.0:Left Section.
1:Center Section
2:Right Section
0:Left Section.
1:Center Section
2:Right Section
[C#]
cells.PageSetup.PrintTitleColumns = "$A:$A";
[Visula Basic]
cells.PageSetup.PrintTitleColumns = "$A:$A"
[C#]
cells.PageSetup.PrintTitleRows = "$1:$1";
[Visula Basic]
cells.PageSetup.PrintTitleRows = "$1:$1"
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//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
Aspose.Cells.Cell cell = worksheet.Cells["A1"];
//Adding some value to the "A1" cell
cell.PutValue("Hello Aspose!");
Aspose.Cells.Font font = cell.Style.Font;
//Setting the font name to "Times New Roman"
font.Name = "Times New Roman";
//Setting font size to 14
font.Size = 14;
//setting font color as Red
font.Color = System.Drawing.Color.Red;
//Saving the Excel file
workbook.Save(@"d:\dest.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Accessing the "A1" cell from the worksheet
Dim cell As Aspose.Cells.Cell = worksheet.Cells("A1")
'Adding some value to the "A1" cell
cell.PutValue("Hello Aspose!")
Dim font As Aspose.Cells.Font = cell.Style.Font
'Setting the font name to "Times New Roman"
font.Name = "Times New Roman"
'Setting font size to 14
font.Size = 14
'setting font color as Red
font.Color = System.Drawing.Color.Red
'Saving the Excel file
workbook.Save("d:\dest.xls")
[C#]
Style style;
..........
Font font = style.Font;
font.Name = "Times New Roman";
[Visual Basic]
Dim style As Style
..........
Dim font As Font = style.Font
font.Name = "Times New Roman"
PivotFieldType.Row |
PivotFieldType.Column |
PivotFieldType.Data |
PivotFieldType.Page |
PivotFieldType.Row |
PivotFieldType.Column |
PivotFieldType.Data |
PivotFieldType.Page |
[C#]
MetadataOptions options = new MetadataOptions(MetadataType.DocumentProperties);
WorkbookMetadata meta = new WorkbookMetadata(path + "book1.xlsx", options);
meta.CustomDocumentProperties.Add("test", "test");
meta.Save(path + "book2.xlsx");
Setting | Description |
True | The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null. |
False | (Default) The control will cycle through states for Yes and No values. Null values display as if they were No values. |
Setting | Description |
True | The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null. |
False | (Default) The control will cycle through states for Yes and No values. Null values display as if they were No values. |
[C#]
Workbook wb = new Workbook("connection.xlsx");
ExternalConnectionCollection dataConns = wb.DataConnections;
ExternalConnection dataConn = null;
for (int i = 0; i < dataConns.Count; i++)
{
dataConn = dataConns[i];
//get external connection id
Console.WriteLine(dataConn.ConnectionId);
}
[Visual Basic]
Dim wb As Workbook = New Workbook("connection.xlsx")
Dim dataConns As ExternalConnectionCollection = wb.DataConnections
Dim dataConn As ExternalConnection
Dim count As Integer = dataConns.Count - 1
Dim i As Integer
For i = 0 To count Step 1
dataConn = dataConns(i)
'get external connection id
Console.WriteLine(dataConn.ConnectionId)
Next
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Get Conditional Formatting
ConditionalFormattingCollection cformattings = sheet.ConditionalFormattings;
//Adds an empty conditional formatting
int index = cformattings.Add();
//Get newly added Conditional formatting
FormatConditionCollection fcs = cformattings[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);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
//Sets condition
int idx = fcs.AddCondition(FormatConditionType.IconSet);
FormatCondition cond = fcs[idx];
//Sets condition's type
cond.IconSet.Type = IconSetType.ArrowsGray3;
//Add custom iconset condition.
ConditionalFormattingIcon cfIcon = cond.IconSet.CfIcons[0];
cfIcon.Type = IconSetType.Arrows3;
cfIcon.Index = 0;
ConditionalFormattingIcon cfIcon1 = cond.IconSet.CfIcons[1];
cfIcon1.Type = IconSetType.ArrowsGray3;
cfIcon1.Index = 1;
ConditionalFormattingIcon cfIcon2 = cond.IconSet.CfIcons[2];
cfIcon2.Type = IconSetType.Boxes5;
cfIcon2.Index = 2;
//Saving the Excel file
workbook.Save("C:\\output.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Get Conditional Formatting
Dim cformattings As ConditionalFormattingCollection = sheet.ConditionalFormattings
'Adds an empty conditional formatting
Dim index As Integer = cformattings.Add()
'Get newly added Conditional formatting
Dim fcs As FormatConditionCollection = cformattings(index)
'Sets the conditional format range.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
ca = New CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.AddArea(ca)
//Sets condition
Dim idx As Integer =fcs.AddCondition(FormatConditionType.IconSet)
Dim cond As FormatCondition=fcs[idx]
//Sets condition's type
cfIcon.Type = IconSetType.ArrowsGray3
'Add custom iconset condition.
Dim cfIcon As ConditionalFormattingIcon = cond.IconSet.CfIcons[0]
cfIcon.Type = IconSetType.Arrows3
cfIcon.Index=0
Dim cfIcon1 As ConditionalFormattingIcon = cond.IconSet.CfIcons[1]
cfIcon1.Type = IconSetType.ArrowsGray3
cfIcon1.Index=1
Dim cfIcon2 As ConditionalFormattingIcon = cond.IconSet.CfIcons[2]
cfIcon2.Type = IconSetType.Boxes5
cfIcon2.Index=2
'Saving the Excel file
workbook.Save("C:\output.xls")
[C#]
//custom implementation of IExportObjectListener
class CustomExportObjectListener : IExportObjectListener
{
private int imgIdx = 0;
public object ExportObject(ExportObjectEvent e)
{
Object source = e.GetSource();
if (source is Shape)
{
Shape shape = (Shape)source;
string url = null;
switch (shape.MsoDrawingType)
{
case MsoDrawingType.Picture:
{
url = SaveImage(((Picture)shape).Data, imgIdx, ((Picture)shape).ImageFormat);
break;
}
}
if (url != null)
{
imgIdx++;
}
return url;
}
return null;
}
private string SaveImage(byte[] data, int imgIdx, ImageFormat format)
{
//here save the image to any location, then return the url(relative or absolute) that the generated html can get the image
return "temp1/temp2.png";
}
}
//Save html file with custom listener
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.ExportObjectListener = new CustomExportObjectListener();
Stream stream = File.Create(outfn);
book.Save(stream, saveOptions);
stream.Flush();
stream.Close();
[C#]
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
for (int i = 0; i <5; i++)
{
cells[0,i].PutValue(CellsHelper.ColumnIndexToName(i));
}
for (int row = 1; row <10; row++)
{
for (int column = 0; column <5; column++)
{
cells[row, column].PutValue(row * column);
}
}
ListObjectCollection tables = workbook.Worksheets[0].ListObjects;
int index = tables.Add(0, 0, 9, 4, true);
ListObject table = tables[0];
table.ShowTotals = true;
table.ListColumns[4].TotalsCalculation = Aspose.Cells.TotalsCalculation.Sum;
workbook.Save(@"C:\Book1.xlsx");
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
For i As Int32 = 0 To 4
cells(0, i).PutValue(CellsHelper.ColumnIndexToName(i))
Next
For row As Int32 = 1 To 9
For column As Int32 = 0 To 4
cells(row, column).PutValue(row * column)
Next
Next
Dim tables As ListObjectCollection = workbook.Worksheets(0).ListObjects
Dim index As Int32 = tables.Add(0, 0, 9, 4, True)
Dim table As ListObject = tables(0)
table.ShowTotals = True
table.ListColumns(4).TotalsCalculation = Aspose.Cells.TotalsCalculation.Sum
workbook.Save("C:\Book1.xlsx")
[C#]
Workbook workbook = new Workbook();
ValidationCollection validations = workbook.Worksheets[0].Validations;
Validation validation = validations[validations.Add()];
validation.Type = Aspose.Cells.ValidationType.WholeNumber;
validation.Operator = OperatorType.Between;
validation.Formula1 = "3";
validation.Formula2 = "1234";
CellArea area;
area.StartRow = 0;
area.EndRow = 1;
area.StartColumn = 0;
area.EndColumn = 1;
validation.AddArea(area);
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim validations as ValidationCollection = workbook.Worksheets(0).Validations
Dim validation as Validation = validations(validations.Add())
validation.Type = ValidationType.WholeNumber
validation.Operator = OperatorType.Between
validation.Formula1 = "3"
validation.Formula2 = "1234"
Dim area as CellArea
area.StartRow = 0
area.EndRow = 1
area.StartColumn = 0
area.EndColumn = 1
validation.AddArea(area)
[C#]
//Set Image Or Print Options
ImageOrPrintOptions options = new ImageOrPrintOptions();
//set Horizontal resolution
options.HorizontalResolution = 200;
//set Vertica; Resolution
options.VerticalResolution = 300;
//Instantiate Workbook
Workbook book = new Workbook(@"c:\test.xls");
//Save chart as Image using ImageOrPrint Options
Bitmap chartObject = book.Worksheets[0].Charts[0].ToImage(options);
[VB.NET]
'Set Image Or Print Options
Dim options As New ImageOrPrintOptions()
'set Horizontal resolution
options.HorizontalResolution = 200
'set Vertica; Resolution
options.VerticalResolution = 300
'Instantiate Workbook
Dim book As New Workbook("c:\test.xls")
'Save chart as Image using ImageOrPrint Options
Dim chartObject As Bitmap = book.Worksheets(0).Charts(0).ToImage(options)
[C#]
Workbook workbook = new Workbook();
ErrorCheckOptionCollection opts = workbook.Worksheets[0].ErrorCheckOptions;
int optionIdx = opts.Add();
ErrorCheckOption opt = opts[optionIdx];
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.InconsistFormula, false);
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.InconsistRange, false);
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.TextDate, false);
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.TextNumber, false);
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.Validation, false);
opt.AddRange(CellArea.CreateCellArea("A1", "B10"));
workbook.Save(@"D:\Filetemp\Book1.xlsx");
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim opts As ErrorCheckOptionCollection = workbook.Worksheets(0).ErrorCheckOptions
Dim optionIdx As Integer = opts.Add()
Dim opt As ErrorCheckOption = opts(optionIdx)
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.InconsistFormula, False)
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.InconsistRange, False)
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.TextDate, False)
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.TextNumber, False)
opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.Validation, False)
opt.AddRange(CellArea.CreateCellArea("A1", "B10"))
workbook.Save("D:\Filetemp\Book1.xlsx")
[C#]
License license = new License();
license.SetLicense("MyLicense.lic");
[Visual Basic]
Dim license As license = New license
License.SetLicense("MyLicense.lic")
[C#]
License license = new License();
license.SetLicense("MyLicense.lic");
[Visual Basic]
Dim license As license = New license
License.SetLicense("MyLicense.lic")
Tries to find the license in the following locations:
1. Explicit path.
2. The folder that contains the Aspose component assembly.
3. The folder that contains the client's calling assembly.
4. The folder that contains the entry (startup) assembly.
5. An embedded resource in the client's calling assembly.
Note:On the .NET Compact Framework, tries to find the license only in these locations:
1. Explicit path.
2. An embedded resource in the client's calling assembly.
[C#]
License license = new License();
license.SetLicense("MyLicense.lic");
[Visual Basic]
Dim license As License = New License
license.SetLicense("MyLicense.lic")
Can be a full or short file name or name of an embedded resource.
Use an empty string to switch to evaluation mode.Use this method to load a license from a stream.
[C#]
License license = new License();
license.SetLicense(myStream);
[Visual Basic]
Dim license as License = new License
license.SetLicense(myStream)
[C#]
//Create a connection object, specify the provider info and set the data source.
OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=d:\\test\\Northwind.mdb");
//Open the connection object.
con.Open();
//Create a command object and specify the SQL query.
OleDbCommand cmd = new OleDbCommand("Select * from [Order Details]", con);
//Create a data adapter object.
OleDbDataAdapter da = new OleDbDataAdapter();
//Specify the command.
da.SelectCommand = cmd;
//Create a dataset object.
DataSet ds = new DataSet();
//Fill the dataset with the table records.
da.Fill(ds, "Order Details");
//Create a datatable with respect to dataset table.
DataTable dt = ds.Tables["Order Details"];
//Create WorkbookDesigner object.
WorkbookDesigner wd = new WorkbookDesigner();
//Open the template file (which contains smart markers).
wd.Open("D:\\test\\SmartMarker_Designer.xls");
//Set the datatable as the data source.
wd.SetDataSource(dt);
//Process the smart markers to fill the data into the worksheets.
wd.Process(true);
//Save the excel file.
wd.Workbook.Save("D:\\test\\outSmartMarker_Designer.xls");
[Visual Basic]
'Create a connection object, specify the provider info and set the data source.
Dim con As OleDbConnection = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=d:\test\Northwind.mdb")
'Open the connection object.
con.Open()
'Create a command object and specify the SQL query.
Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Order Details]", con)
'Create a data adapter object.
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
'Specify the command.
da.SelectCommand = cmd
'Create a dataset object.
Dim ds As DataSet = New DataSet()
'Fill the dataset with the table records.
da.Fill(ds, "Order Details")
'Create a datatable with respect to dataset table.
Dim dt As DataTable = ds.Tables("Order Details")
'Create WorkbookDesigner object.
Dim wd As WorkbookDesigner = New WorkbookDesigner()
'Open the template file (which contains smart markers).
wd.Open("D:\test\SmartMarker_Designer.xls")
'Set the datatable as the data source.
wd.SetDataSource(dt)
'Process the smart markers to fill the data into the worksheets.
wd.Process(True)
'Save the excel file.
wd.Workbook.Save("D:\test\outSmartMarker_Designer.xls")
[C#]
internal void ValidateSignature()
{
Workbook wb = new Workbook(@"c:\newfile.xlsx");
//wb.IsDigitallySigned is true when the workbook is signed already.
System.Console.WriteLine(wb.IsDigitallySigned);
//get digitalSignature collection from workbook
DigitalSignatureCollection dsc = wb.GetDigitalSignature();
foreach (DigitalSignature ds in dsc)
{
System.Console.WriteLine(ds.Comments);
System.Console.WriteLine(ds.SignTime);
System.Console.WriteLine(ds.IsValid);
}
}
internal void SignSignature()
{
//dsc is signature collection contains one or more signature needed to sign
DigitalSignatureCollection dsc = new DigitalSignatureCollection();
//cert must contain private key, it can be contructed from cert file or windows certificate collection.
//123456 is password of cert
X509Certificate2 cert = new X509Certificate2("c:\\mykey2.pfx", "123456");
DigitalSignature ds = new DigitalSignature(cert, "test for sign", DateTime.Now);
dsc.Add(ds);
Workbook wb = new Workbook();
//wb.SetDigitalSignature sign all signatures in dsc
wb.SetDigitalSignature(dsc);
wb.Save(@"c:\newfile.xlsx");
}
[Visual Basic]
Sub ValidateSignature()
Dim workbook As Workbook = New Workbook("c:\newfile.xlsx")
'Workbook.IsDigitallySigned is true when the workbook is signed already.
System.Console.WriteLine(workbook.IsDigitallySigned)
'get digitalSignature collection from workbook
Dim dsc As DigitalSignatureCollection = workbook.GetDigitalSignature()
Dim ds As DigitalSignature
For Each ds In dsc
System.Console.WriteLine(ds.Comments)
System.Console.WriteLine(ds.SignTime)
System.Console.WriteLine(ds.IsValid)
Next
End Sub
Sub SignSignature()
'dsc is signature collection contains one or more signature needed to sign
Dim dsc As DigitalSignatureCollection = New DigitalSignatureCollection()
'cert must contain private key, it can be contructed from cert file or windows certificate collection.
Dim cert As X509Certificate2 = New X509Certificate2("c:\mykey2.pfx", "123456")
'create a signature with certificate, sign purpose and sign time
Dim ds As DigitalSignature = New DigitalSignature(cert, "test for sign", DateTime.Now)
dsc.Add(ds)
Dim workbook As Workbook = New Workbook()
'workbook.SetDigitalSignature sign all signatures in dsc
workbook.SetDigitalSignature(dsc)
workbook.Save("c:\newfile.xlsx")
End Sub
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditions fcs = sheet.ConditionalFormattings[index];
//Sets the conditional format range.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 2;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
//Adds condition.
int idx = fcs.AddCondtion(FormatConditionType.DataBar);
fcs.AddArea(ca);
FormatCondition cond = fcs[idx];
//Get Databar
DataBar dataBar = cond.DataBar;
dataBar.Color = Color.Orange;
//Set Databar properties
dataBar.MinCfvo.Type = FormatConditionValueType.Percentile;
dataBar.MinCfvo.Value = 30;
dataBar.ShowValue = false;
dataBar.BarBorder.Type = DataBarBorderType.DataBarBorderSolid;
dataBar.BarBorder.Color = Color.Plum;
dataBar.BarFillType = DataBarFillType.DataBarFillSolid;
dataBar.AxisColor = Color.Red;
dataBar.AxisPosition = DataBarAxisPosition.DataBarAxisMidpoint;
dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.DataBarColor;
dataBar.NegativeBarFormat.Color = Color.White;
dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.DataBarColor;
dataBar.NegativeBarFormat.BorderColor = Color.Yellow;
//Put Cell Values
Aspose.Cells.Cell cell1 = sheet.Cells["A1"];
cell1.PutValue(10);
Aspose.Cells.Cell cell2 = sheet.Cells["A2"];
cell2.PutValue(120);
Aspose.Cells.Cell cell3 = sheet.Cells["A3"];
cell3.PutValue(260);
//Saving the Excel file
workbook.Save("D:\\book1.xlsx");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Adds an empty conditional formatting
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditions = sheet.ConditionalFormattings(index)
'Sets the conditional format range.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 2
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
'Adds condition.
Dim idx As Integer = fcs.AddCondtion(FormatConditionType.DataBar)
fcs.AddArea(ca)
Dim cond As FormatCondition = fcs(idx)
'Get Databar
Dim dataBar As DataBar = cond.DataBar
dataBar.Color = Color.Orange
'Set Databar properties
dataBar.MinCfvo.Type = FormatConditionValueType.Percentile
dataBar.MinCfvo.Value = 30
dataBar.ShowValue = False
dataBar.BarBorder.Type = DataBarBorderType.DataBarBorderSolid
dataBar.BarBorder.Color = Color.Plum
dataBar.BarFillType = DataBarFillType.DataBarFillSolid
dataBar.AxisColor = Color.Red
dataBar.AxisPosition = DataBarAxisPosition.DataBarAxisMidpoint
dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.DataBarColor
dataBar.NegativeBarFormat.Color = Color.White
dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.DataBarColor
dataBar.NegativeBarFormat.BorderColor = Color.Yellow
'Put Cell Values
Dim cell1 As Aspose.Cells.Cell = sheet.Cells("A1")
cell1.PutValue(10)
Dim cell2 As Aspose.Cells.Cell = sheet.Cells("A2")
cell2.PutValue(120)
Dim cell3 As Aspose.Cells.Cell = sheet.Cells("A3")
cell3.PutValue(260)
'Saving the Excel file
workbook.Save("D:\book1.xlsx")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditions fcs = sheet.ConditionalFormattings[index];
//Sets the conditional format range.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 2;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
//Adds condition.
int idx = fcs.AddCondtion(FormatConditionType.IconSet);
fcs.AddArea(ca);
FormatCondition cond = fcs[idx];
//Get Icon Set
IconSet iconSet = cond.IconSet;
//Set Icon Type
iconSet.Type = IconSetType.Arrows3;
//Put Cell Values
Aspose.Cells.Cell cell1 = sheet.Cells["A1"];
cell1.PutValue(10);
Aspose.Cells.Cell cell2 = sheet.Cells["A2"];
cell2.PutValue(120);
Aspose.Cells.Cell cell3 = sheet.Cells["A3"];
cell3.PutValue(260);
//Saving the Excel file
workbook.Save("D:\\book1.xlsx");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Adds an empty conditional formatting
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditions = sheet.ConditionalFormattings(index)
'Sets the conditional format range.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 2
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
'Adds condition.
Dim idx As Integer = fcs.AddCondtion(FormatConditionType.IconSet)
fcs.AddArea(ca)
Dim cond As FormatCondition = fcs(idx)
'Get Icon Set
Dim iconSet As IconSet = cond.IconSet
'Set Icon Type
iconSet.Type = IconSetType.Arrows3
'Put Cell Values
Dim cell1 As Aspose.Cells.Cell = sheet.Cells("A1")
cell1.PutValue(10)
Dim cell2 As Aspose.Cells.Cell = sheet.Cells("A2")
cell2.PutValue(120)
Dim cell3 As Aspose.Cells.Cell = sheet.Cells("A3")
cell3.PutValue(260)
'Saving the Excel file
workbook.Save("D:\book1.xlsx")
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
The plot-area bounding box includes the plot area, tick marks(tick labels), and a small border around the tick marks. If the value is not created by MS Excel, please call Chart.Calculate() method before calling this method.
The X, Y, Width and Height of PlotArea represents the plot-area bounding box that includes the plot area, tick marks(tick labels), and a small border around the tick marks. If you want to get actual size of plot area, you should call InnerX, InnerY, InnerWidth and InnerHeight properties.
For excel 2007 or latter, the default value is zero. you should call get the value after calling Chart.Calculate().
[C#]
//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
//Add an arc shape.
Aspose.Cells.ArcShape arc1 = excelbook.Worksheets[0].Shapes.AddArc(2, 0, 2, 0, 130, 130);
//Set the placement of the arc.
arc1.Placement = PlacementType.FreeFloating;
//Set the fill format.
arc1.FillFormat.ForeColor = Color.Blue;
//Set the line style.
arc1.LineFormat.Style = MsoLineStyle.Single;
//Set the line weight.
arc1.LineFormat.Weight = 1;
//Set the color of the arc line.
arc1.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the arc.
arc1.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Add another arc shape.
Aspose.Cells.ArcShape arc2 = excelbook.Worksheets[0].Shapes.AddArc(9, 0, 2, 0, 130, 130);
//Set the placement of the arc.
arc2.Placement = PlacementType.FreeFloating;
//Set the line style.
arc2.LineFormat.Style = MsoLineStyle.Single;
//Set the line weight.
arc2.LineFormat.Weight = 1;
//Set the color of the arc line.
arc2.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the arc.
arc2.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Save the excel file.
excelbook.Save("d:\\test\\tstarcs.xls");
[VB..NET]
'Instantiate a new Workbook.
Dim excelbook As Workbook = New Workbook()
'Add an arc shape.
Dim arc1 As Aspose.Cells.ArcShape = excelbook.Worksheets(0).Shapes.AddArc(2, 0, 2, 0, 130, 130)
'Set the placement of the arc.
arc1.Placement = PlacementType.FreeFloating
'Set the fill format.
arc1.FillFormat.ForeColor = Color.Blue
'Set the line style.
arc1.LineFormat.Style = MsoLineStyle.Single
'Set the line weight.
arc1.LineFormat.Weight = 1
'Set the color of the arc line.
arc1.LineFormat.ForeColor = Color.Blue
'Set the dash style of the arc.
arc1.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Add another arc shape.
Dim arc2 As Aspose.Cells.ArcShape = excelbook.Worksheets(0).Shapes.AddArc(9, 0, 2, 0, 130, 130)
'Set the placement of the arc.
arc2.Placement = PlacementType.FreeFloating
'Set the line style.
arc2.LineFormat.Style = MsoLineStyle.Single
'Set the line weight.
arc2.LineFormat.Weight = 1
'Set the color of the arc line.
arc2.LineFormat.ForeColor = Color.Blue
'Set the dash style of the arc.
arc2.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Save the excel file.
excelbook.Save("d:\test\tstarcs.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Setting the foreground color of the plot area
chart.PlotArea.Area.ForegroundColor = Color.Blue;
//Setting the foreground color of the chart area
chart.ChartArea.Area.ForegroundColor = Color.Yellow;
//Setting the foreground color of the 1st NSeries area
chart.NSeries[0].Area.ForegroundColor = Color.Red;
//Setting the foreground color of the area of the 1st NSeries point
chart.NSeries[0].Points[0].Area.ForegroundColor = Color.Cyan;
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Workbook object
Dim sheetIndex As Integer = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Setting the foreground color of the plot area
chart.PlotArea.Area.ForegroundColor = Color.Blue
'Setting the foreground color of the chart area
chart.ChartArea.Area.ForegroundColor = Color.Yellow
'Setting the foreground color of the 1st NSeries area
chart.NSeries(0).Area.ForegroundColor = Color.Red
'Setting the foreground color of the area of the 1st NSeries point
chart.NSeries(0).Points(0).Area.ForegroundColor = Color.Cyan
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(-100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "A3"
chart.NSeries.Add("A1:A3", true);
chart.NSeries[0].Area.InvertIfNegative = true;
//Setting the foreground color of the 1st NSeries area
chart.NSeries[0].Area.ForegroundColor = Color.Red;
//Setting the background color of the 1st NSeries area.
//The displayed area color of second chart point will be the background color.
chart.NSeries[0].Area.BackgroundColor = Color.Yellow;
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Workbook object
Dim sheetIndex As Integer = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(-100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "A3"
chart.NSeries.Add("A1:A3", True)
chart.NSeries(0).Area.InvertIfNegative = True
'Setting the foreground color of the 1st NSeries area
chart.NSeries(0).Area.ForegroundColor = Color.Red
'Setting the background color of the 1st NSeries area.
'The displayed area color of second chart point will be the background color.
chart.NSeries(0).Area.BackgroundColor = Color.Yellow
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "A4" cell
worksheet.Cells["A4"].PutValue(200);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a sample value to "B4" cell
worksheet.Cells["B4"].PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.Cells["C1"].PutValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.Cells["C2"].PutValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.Cells["C3"].PutValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.Cells["C4"].PutValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4";
Series series = chart.NSeries[1];
//Setting the values of the series.
series.Values = "=B1:B4";
//Changing the chart type of the series.
series.Type = ChartType.Line;
//Setting marker properties.
series.MarkerStyle = ChartMarkerType.Circle;
series.MarkerForegroundColorSetType = FormattingType.Automatic;
series.MarkerForegroundColor = System.Drawing.Color.Black;
series.MarkerBackgroundColorSetType = FormattingType.Automatic;
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "A4" cell
worksheet.Cells("A4").PutValue(200)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a sample value to "B4" cell
worksheet.Cells("B4").PutValue(40)
'Adding a sample value to "C1" cell as category data
worksheet.Cells("C1").PutValue("Q1")
'Adding a sample value to "C2" cell as category data
worksheet.Cells("C2").PutValue("Q2")
'Adding a sample value to "C3" cell as category data
worksheet.Cells("C3").PutValue("Y1")
'Adding a sample value to "C4" cell as category data
worksheet.Cells("C4").PutValue("Y2")
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", True)
'Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4"
Dim series As Series = chart.NSeries(1)
'Setting the values of the series.
series.Values = "=B1:B4"
'Changing the chart type of the series.
series.Type = ChartType.Line
'Setting marker properties.
series.MarkerStyle = ChartMarkerType.Circle
series.MarkerForegroundColorSetType = FormattingType.Automatic
series.MarkerForegroundColor = System.Drawing.Color.Black
series.MarkerBackgroundColorSetType = FormattingType.Automatic
'Saving the Excel file
workbook.Save("C:\\book1.xls")
[C#]
//Reference name to a cell
chart.NSeries[0].Name = "=A1";
//Set a string to name
chart.NSeries[0].Name = "First Series";
[Visual Basic]
'Reference name to a cell
chart.NSeries[0].Name = "=A1"
'Set a string to name
chart.NSeries[0].Name = "First Series"
[C#]
//Instantiate the workbook object
Workbook workbook = new Workbook("C:\\book1.xls");
//Get Cells collection
Cells cells = workbook.Worksheets[0].Cells;
//Instantiate FindOptions Object
FindOptions findOptions = new FindOptions();
//Create a Cells Area
CellArea ca = new CellArea();
ca.StartRow = 8;
ca.StartColumn = 2;
ca.EndRow = 17;
ca.EndColumn = 13;
//Set cells area for find options
findOptions.SetRange(ca);
//Set searching properties
findOptions.SearchBackward = false;
findOptions.SeachOrderByRows = true;
findOptions.LookInType = LookInType.Values;
//Find the cell with 0 value
Cell cell = cells.Find(0, null, findOptions);
[VB.NET]
'Instantiate the workbook object
Dim workbook As New Workbook("C:\book1.xls")
'Get Cells collection
Dim cells As Cells = workbook.Worksheets(0).Cells
'Instantiate FindOptions Object
Dim findOptions As New FindOptions()
'Create a Cells Area
Dim ca As New CellArea()
ca.StartRow = 8
ca.StartColumn = 2
ca.EndRow = 17
ca.EndColumn = 13
'Set cells area for find options
findOptions.SetRange(ca)
'Set searching properties
findOptions.SearchBackward = True
findOptions.SeachOrderByRows = True
findOptions.LookInType = LookInType.Values
'Find the cell with 0 value
Dim cell As Cell = cells.Find(0, Nothing, findOptions)
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(4);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(20);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Set the max value of value axis
chart.ValueAxis.MaxValue = 200;
//Set the min value of value axis
chart.ValueAxis.MinValue = 0;
//Set the major unit
chart.ValueAxis.MajorUnit = 25;
//Category(X) axis crosses at the maxinum value.
chart.ValueAxis.Crosses = CrossType.Maximum;
//Set he number of categories or series between tick-mark labels.
chart.CategoryAxis.TickLabelSpacing = 2;
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(4)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(20)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Set the max value of value axis
chart.ValueAxis.MaxValue = 200
'Set the min value of value axis
chart.ValueAxis.MinValue = 0
'Set the major unit
chart.ValueAxis.MajorUnit = 25
'Category(X) axis crosses at the maxinum value.
chart.ValueAxis.Crosses = CrossType.Maximum
'Set he number of categories or series between tick-mark labels.
chart.CategoryAxis.TickLabelSpacing = 2
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
chart.CategoryAxis.CategoryType = CategoryType.TimeScale;
chart.CategoryAxis.MajorUnitScale = TimeUnit.Months;
chart.CategoryAxis.MajorUnit = 2;
[Visual Basic]
chart.CategoryAxis.CategoryType = CategoryType.TimeScale
chart.CategoryAxis.MajorUnitScale = TimeUnit.Months
chart.CategoryAxis.MajorUnit = 2
[C#]
chart.CategoryAxis.CategoryType = CategoryType.TimeScale;
chart.CategoryAxis.MinorUnitScale = TimeUnit.Months;
chart.CategoryAxis.MinorUnit = 2;
[Visual Basic]
chart.CategoryAxis.CategoryType = CategoryType.TimeScale
chart.CategoryAxis.MinorUnitScale = TimeUnit.Months
chart.CategoryAxis.MinorUnit = 2
[C#]
chart.ValueAxis.MajorGridLines.IsVisible = false;
chart.CategoryAxis.MajorGridLines.IsVisible = true;
[Visual Basic]
chart.ValueAxis.MajorGridLines.IsVisible = false
chart.CategoryAxis.MajorGridLines.IsVisible = true
[C#]
Style style = cell.GetStyle();
//Set top border style and color
Border border = style.Borders[BorderType.TopBorder];
border.LineStyle = CellBorderType.Medium;
border.Color = Color.Red;
cell.SetStyle(style);
[Visual Basic]
Dim style as Style = cell.GetStyle()
'Set top border style and color
Dim border as Border = style.Borders(BorderType.TopBorder)
border.LineStyle = CellBorderType.Medium
border.Color = Color.Red
cell.SetStyle(style);
[C#]
//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("Visit Aspose!");
Style style = cell.GetStyle();
//Setting the line style of the top border
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thick;
//Setting the color of the top border
style.Borders[BorderType.TopBorder].Color = Color.Black;
//Setting the line style of the bottom border
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thick;
//Setting the color of the bottom border
style.Borders[BorderType.BottomBorder].Color = Color.Black;
//Setting the line style of the left border
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thick;
//Setting the color of the left border
style.Borders[BorderType.LeftBorder].Color = Color.Black;
//Setting the line style of the right border
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thick;
//Setting the color of the right border
style.Borders[BorderType.RightBorder].Color = Color.Black;
cell.SetStyle(style);
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Workbook object
workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Accessing the "A1" cell from the worksheet
Dim cell As Cell = worksheet.Cells("A1")
'Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!")
Dim style as Style = cell.GetStyle()
'Setting the line style of the top border
style.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thick
'Setting the color of the top border
style.Borders(BorderType.TopBorder).Color = Color.Black
'Setting the line style of the bottom border
style.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thick
'Setting the color of the bottom border
style.Borders(BorderType.BottomBorder).Color = Color.Black
'Setting the line style of the left border
style.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thick
'Setting the color of the left border
style.Borders(BorderType.LeftBorder).Color = Color.Black
'Setting the line style of the right border
style.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thick
'Setting the color of the right border
style.Borders(BorderType.RightBorder).Color = Color.Black
cell.SetStyle(style)
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the workbook.
Worksheet sheet = workbook.Worksheets[0];
//Add a new button to the worksheet.
Aspose.Cells.Button button = sheet.Shapes.AddButton(2, 0, 2, 0, 28, 80);
//Set the caption of the button.
button.Text = "Aspose";
//Set the Placement Type, the way the
//button is attached to the cells.
button.Placement = PlacementType.FreeFloating;
//Set the font name.
button.Font.Name = "Tahoma";
//Set the caption string bold.
button.Font.IsBold = true;
//Set the color to blue.
button.Font.Color = Color.Blue;
//Set the hyperlink for the button.
button.AddHyperlink("http://www.aspose.com/");
//Saves the file.
workbook.Save(@"d:\test\tstbutton.xls");
[VB.NET]
'Create a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet in the workbook.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Add a new button to the worksheet.
Dim button As Aspose.Cells.Button = sheet.Shapes.AddButton(2, 0, 2, 0, 28, 80)
'Set the caption of the button.
button.Text = "Aspose"
'Set the Placement Type, the way the
'button is attached to the cells.
button.Placement = PlacementType.FreeFloating
'Set the font name.
button.Font.Name = "Tahoma"
'Set the caption string bold.
button.Font.IsBold = True
'Set the color to blue.
button.Font.Color = Color.Blue
'Set the hyperlink for the button.
button.AddHyperlink("http://www.aspose.com/")
'Saves the file.
workbook.Save("d:\test\tstbutton.xls")
[C#]
//Create Cell Area
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
[VB.NET]
'Create Cell Area
Dim ca As CellArea = New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
[C#]
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells[0,1].PutValue("Income");
cells[1,0].PutValue("Company A");
cells[2,0].PutValue("Company B");
cells[3,0].PutValue("Company C");
cells[1,1].PutValue(10000);
cells[2,1].PutValue(20000);
cells[3,1].PutValue(30000);
int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);
Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add("B2:B4", true);
chart.NSeries.CategoryData = "A2:A4";
ASeries aSeries = chart.NSeries[0];
aSeries.Name = "=B1";
chart.IsLegendShown = true;
chart.Title.Text = "Income Analysis";
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim sheet as Worksheet = workbook.Worksheets(0)
Dim cells as Cells = sheet.Cells
cells(0,1).PutValue("Income")
cells(1,0).PutValue("Company A")
cells(2,0).PutValue("Company B")
cells(3,0).PutValue("Company C")
cells(1,1).PutValue(10000)
cells(2,1).PutValue(20000)
cells(3,1).PutValue(30000)
Dim chartIndex as Integer = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15)
Dim chart as Chart = sheet.Charts(chartIndex)
chart.NSeries.Add("B2:B4", true)
chart.NSeries.CategoryData = "A2:A4"
Dim aSeries as ASeries = chart.NSeries(0)
aSeries.Name = "=B1"
chart.IsLegendShown = true
chart.Title.Text = "Income Analysis"
[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 200;
options.VerticalResolution = 300;
Workbook book = new Workbook(@"c:\test.xls");
Bitmap chartObject = book.Worksheets[0].Charts[0].ToImage(options);
[VB]
Dim options As ImageOrPrintOptions = New ImageOrPrintOptions()
options.HorizontalResolution = 200
options.VerticalResolution = 300
Dim book As Workbook = New Workbook("c:\test.xls")
Dim chartObject As Bitmap = book.Worksheets(0).Charts(0).ToImage(options)
The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.The format of the image is specified by using
The format of the image is specified by using
The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
options.TiffCompression = TiffCompression.CompressionCCITT4;
Workbook book = new Workbook(@"c:\test.xls");
book.Worksheets[0].Charts[0].ToImage(@"c:\chart.Tiff", options);
[VB]
Dim options As ImageOrPrintOptions = New ImageOrPrintOptions()
options.HorizontalResolution = 300
options.VerticalResolution = 300
options.TiffCompression = TiffCompression.CompressionCCITT4
Dim book As Workbook = New Workbook("c:\test.xls")
book.Worksheets(0).Charts(0).ToImage("c:\chart.Tiff", options)
Saves to Jpeg with 300 dpi and 80 image quality.
[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
options.Quality = 80;
Workbook book = new Workbook(@"c:\test.xls");
book.Worksheets[0].Charts[0].ToImage(@"c:\chart.Jpeg", options);
[VB]
Dim options As ImageOrPrintOptions = New ImageOrPrintOptions()
options.HorizontalResolution = 300
options.VerticalResolution = 300
options.Quality = 80
Dim book As Workbook = New Workbook("c:\test.xls")
book.Worksheets(0).Charts(0).ToImage("c:\chart.Jpeg", options)
The format of the image is specified by using
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Getting Chart Area
ChartArea chartArea = chart.ChartArea;
//Setting the foreground color of the chart area
chartArea.Area.ForegroundColor = Color.Yellow;
//Setting Chart Area Shadow
chartArea.Shadow = true;
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Getting Chart Area
Dim chartArea As ChartArea = chart.ChartArea
'Setting the foreground color of the chart area
chartArea.Area.ForegroundColor = Color.Yellow
'Setting Chart Area Shadow
chartArea.Shadow = True
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 10);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
chart.IsDataTableShown = true;
//Getting Chart Table
ChartDataTable chartTable = chart.ChartDataTable;
//Setting Chart Table Font Color
chartTable.Font.Color = System.Drawing.Color.Red;
//Setting Legend Key VisibilityOptions
chartTable.ShowLegendKey = false;
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 10)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
chart.IsDataTableShown = True
'Getting Chart Table
Dim chartTable As ChartDataTable = chart.ChartDataTable
'Setting Chart Table Font Color
chartTable.Font.Color = System.Drawing.Color.Red
'Setting Legend Key VisibilityOptions
chartTable.ShowLegendKey = False
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Show Data Labels
chart.NSeries[0].DataLabels.IsValueShown = true;
for (int i = 0; i < chart.NSeries[0].Points.Count; i++)
{
//Get Data Point
ChartPoint point = chart.NSeries[0].Points[i];
//Set Pir Explosion
point.Explosion = 15;
//Set Border Color
point.Border.Color = System.Drawing.Color.Red;
}
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Show Data Labels
chart.NSeries(0).DataLabels.IsValueShown = True
For i As Integer = 0 To chart.NSeries(0).Points.Count - 1
'Get Data Point
Dim point As ChartPoint = chart.NSeries(0).Points(i)
'Set Pir Explosion
point.Explosion = 15
'Set Border Color
point.Border.Color = System.Drawing.Color.Red
Next i
'Saving the Excel file
workbook.Save("D:\book1.xls")
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Show Data Labels
chart.NSeries[0].DataLabels.IsValueShown = true;
ChartPointCollection points = chart.NSeries[0].Points;
for (int i = 0; i < points.Count; i++)
{
//Get Data Point
ChartPoint point = points[i];
//Set Pir Explosion
point.Explosion = 15;
//Set Border Color
point.Border.Color = System.Drawing.Color.Red;
}
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Show Data Labels
chart.NSeries(0).DataLabels.IsValueShown = True
Dim points As ChartPointCollection = chart.NSeries(0).Points
For i As Integer = 0 To points.Count - 1
'Get Data Point
Dim point As ChartPoint = points(i)
'Set Pir Explosion
point.Explosion = 15
'Set Border Color
point.Border.Color = System.Drawing.Color.Red
Next i
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
Workbook workbook = new Workbook();
ChartCollection charts = workbook.Worksheets[0].Charts;
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim ChartCollection as Charts = workbook.Worksheets(0).Charts
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Show Data Labels
chart.NSeries[0].DataLabels.IsValueShown = true;
//Getting Chart Shape
ChartShape chartShape = chart.ChartObject;
//Set Lower Right Column
chartShape.LowerRightColumn = 10;
//Set LowerDeltaX
chartShape.LowerDeltaX = 1024;
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.PieExploded, 5, 0, 25, 10)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Show Data Labels
chart.NSeries(0).DataLabels.IsValueShown = True
'Getting Chart Shape
Dim chartShape As ChartShape = chart.ChartObject
'Set Lower Right Column
chartShape.LowerRightColumn = 10
'Set LowerDeltaX
chartShape.LowerDeltaX = 1024
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
int index = excel.Worksheets[0].CheckBoxes.Add(15, 15, 20, 100);
CheckBox checkBox = excel.Worksheets[0].CheckBoxes[index];
checkBox.Text = "Check Box 1";
[Visual Basic]
Dim index as integer = excel.Worksheets(0).CheckBoxes.Add(15, 15, 20, 100)
Dim checkBox as CheckBox = excel.Worksheets(0).CheckBoxes[index];
checkBox.Text = "Check Box 1"
[C#]
int index = excel.Worksheets[0].CheckBoxes.Add(15, 15, 20, 100);
CheckBox checkBox = excel.Worksheets[0].CheckBoxes[index];
checkBox.Text = "Check Box 1";
[Visual Basic]
Dim index as integer = excel.Worksheets(0).CheckBoxes.Add(15, 15, 20, 100)
Dim checkBox as CheckBox = excel.Worksheets(0).CheckBoxes[index];
checkBox.Text = "Check Box 1"
[C#]
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Get the worksheet cells collection.
Cells cells = sheet.Cells;
//Input a value.
cells["B3"].PutValue("Employee:");
//Set it bold.
cells["B3"].Style.Font.IsBold = true;
//Input some values that denote the input range
//for the combo box.
cells["A2"].PutValue("Emp001");
cells["A3"].PutValue("Emp002");
cells["A4"].PutValue("Emp003");
cells["A5"].PutValue("Emp004");
cells["A6"].PutValue("Emp005");
cells["A7"].PutValue("Emp006");
//Add a new combo box.
Aspose.Cells.ComboBox comboBox = sheet.Shapes.AddComboBox(2, 0, 2, 0, 22, 100);
//Set the linked cell;
comboBox.LinkedCell = "A1";
//Set the input range.
comboBox.InputRange = "A2:A7";
//Set no. of list lines displayed in the combo
//box's list portion.
comboBox.DropDownLines = 5;
//Set the combo box with 3-D shading.
comboBox.Shadow = true;
//AutoFit Columns
sheet.AutoFitColumns();
//Saves the file.
workbook.Save(@"d:\test\tstcombobox.xls");
[VB.NET]
'Create a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Get the worksheet cells collection.
Dim cells As Cells = sheet.Cells
'Input a value.
cells("B3").PutValue("Employee:")
'Set it bold.
cells("B3").Style.Font.IsBold = True
'Input some values that denote the input range
'for the combo box.
cells("A2").PutValue("Emp001")
cells("A3").PutValue("Emp002")
cells("A4").PutValue("Emp003")
cells("A5").PutValue("Emp004")
cells("A6").PutValue("Emp005")
cells("A7").PutValue("Emp006")
'Add a new combo box.
Dim comboBox As Aspose.Cells.ComboBox = sheet.Shapes.AddComboBox(2, 0, 2, 0, 22, 100)
'Set the linked cell;
comboBox.LinkedCell = "A1"
'Set the input range.
comboBox.InputRange = "A2:A7"
'Set no. of list lines displayed in the combo
'box's list portion.
comboBox.DropDownLines = 5
'Set the combo box with 3-D shading.
comboBox.Shadow = True
'AutoFit Columns
sheet.AutoFitColumns()
'Saves the file.
workbook.Save("d:\test\tstcombobox.xls")
[C#]
Workbook workbook = new Workbook();
CommentCollection comments = workbook.Worksheets[0].Comments;
//Add comment to cell A1
int commentIndex = comments.Add(0, 0);
Comment comment = comments[commentIndex];
comment.Note = "First note.";
comment.Font.Name = "Times New Roman";
//Add comment to cell B2
comments.Add("B2");
comment = comments["B2"];
comment.Note = "Second note.";
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim comments as CommentCollection = workbook.Worksheets(0).Comments
'Add comment to cell A1
Dim commentIndex as Integer = comments.Add(0, 0)
Dim comment as Comment = comments(commentIndex)
comment.Note = "First note."
comment.Font.Name = "Times New Roman"
'Add comment to cell B2
comments.Add("B2")
comment = comments("B2")
comment.Note = "Second note."
[C#]
Workbook workbook = new Workbook();
CommentCollection comments = workbook.Worksheets[0].Comments;
[Visual Basic]
Dim workbook as Workbook = new Workbook()
Dim comments as CommentCollection = workbook.Worksheets(0).Comments
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Get Conditional Formatting
ConditionalFormattingCollection cformattings = sheet.ConditionalFormattings;
//Adds an empty conditional formatting
int index = cformattings.Add();
//Get newly added Conditional formatting
FormatConditionCollection fcs = cformattings[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);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
//Add condition.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
//Add condition.
int conditionIndex2 = 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("C:\\output.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Get Conditional Formatting
Dim cformattings As ConditionalFormattingCollection = sheet.ConditionalFormattings
'Adds an empty conditional formatting
Dim index As Integer = cformattings.Add()
'Get newly added Conditional formatting
Dim fcs As FormatConditionCollection = cformattings(index)
'Sets the conditional format range.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
ca = New CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.AddArea(ca)
'Add condition.
Dim conditionIndex As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100")
'Add condition.
Dim conditionIndex2 As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100")
'Sets the background color.
Dim fc As FormatCondition = fcs(conditionIndex)
fc.Style.BackgroundColor = Color.Red
'Saving the Excel file
workbook.Save("C:\output.xls")
[C#]
//Set the DataLabels in the chart
DataLabels datalabels;
for (int i = 0; i <chart.NSeries.Count; i++)
{
datalabels = chart.NSeries[i].DataLabels;
//Set the position of DataLabels
datalabels.Position = LabelPositionType.InsideBase;
//Show the category name in the DataLabels
datalabels.ShowCategoryName = true;
//Show the value in the DataLabels
datalabels.ShowValue = true;
//Not show the percentage in the DataLabels
datalabels.ShowPercentage = false;
//Not show the legend key.
datalabels.ShowLegendKey = false;
}
[Visual Basic]
'Set the DataLabels in the chart
Dim datalabels As DataLabels
Dim i As Integer
For i = 0 To chart.NSeries.Count - 1 Step 1
datalabels = chart.NSeries(i).DataLabels
'Set the position of DataLabels
datalabels.Position = LabelPositionType.InsideBase
'Show the category name in the DataLabels
datalabels.ShowCategoryName= True
'Show the value in the DataLabels
datalabels.ShowValue = True
'Not show the percentage in the DataLabels
datalabels.ShowPercentage = False
'Not show the legend key.
datalabels.ShowLegendKey = False
Next
[C#]
//Instantiate a new Workbook object.
Workbook workbook = new Workbook("C:\\Book1.xls");
//Get the workbook datasorter object.
DataSorter sorter = workbook.DataSorter;
//Set the first order for datasorter object.
sorter.Order1 = Aspose.Cells.SortOrder.Descending;
//Define the first key.
sorter.Key1 = 0;
//Set the second order for datasorter object.
sorter.Order2 = Aspose.Cells.SortOrder.Ascending;
//Define the second key.
sorter.Key2 = 1;
//Create a cells area (range).
CellArea ca = new CellArea();
//Specify the start row index.
ca.StartRow = 0;
//Specify the start column index.
ca.StartColumn = 0;
//Specify the last row index.
ca.EndRow = 13;
//Specify the last column index.
ca.EndColumn = 1;
//Sort data in the specified data range (A1:B14)
sorter.Sort(workbook.Worksheets[0].Cells, ca);
//Save the excel file.
workbook.Save("C:\\outBook.xls");
[Visual Basic]
'Instantiate a new Workbook object.
Dim workbook As Workbook = New Workbook("C:\Book1.xls")
'Get the workbook datasorter object.
Dim sorter As DataSorter = workbook.DataSorter
'Set the first order for datasorter object
sorter.Order1 = Aspose.Cells.SortOrder.Descending
'Define the first key.
sorter.Key1 = 0
'Set the second order for datasorter object.
sorter.Order2 = Aspose.Cells.SortOrder.Ascending
'Define the second key.
sorter.Key2 = 1
'Create a cells area (range).
Dim ca As CellArea = New CellArea
'Specify the start row index.
ca.StartRow = 0
'Specify the start column index.
ca.StartColumn = 0
'Specify the last row index.
ca.EndRow = 13
'Specify the last column index.
ca.EndColumn = 1
'Sort the data in the specified data range (A1:B14)
sorter.Sort(workbook.Worksheets(0).Cells, ca)
'Save the excel file.
workbook.Save("C:\outBook.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "A4" cell
worksheet.Cells["A4"].PutValue(200);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a sample value to "B4" cell
worksheet.Cells["B4"].PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.Cells["C1"].PutValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.Cells["C2"].PutValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.Cells["C3"].PutValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.Cells["C4"].PutValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4";
//Setting the display unit of value(Y) axis.
chart.ValueAxis.DisplayUnit = DisplayUnitType.Hundreds;
DisplayUnitLabel displayUnitLabel = chart.ValueAxis.DisplayUnitLabel;
//Setting the custom display unit label
displayUnitLabel.Text = "100";
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "A4" cell
worksheet.Cells("A4").PutValue(200)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a sample value to "B4" cell
worksheet.Cells("B4").PutValue(40)
'Adding a sample value to "C1" cell as category data
worksheet.Cells("C1").PutValue("Q1")
'Adding a sample value to "C2" cell as category data
worksheet.Cells("C2").PutValue("Q2")
'Adding a sample value to "C3" cell as category data
worksheet.Cells("C3").PutValue("Y1")
'Adding a sample value to "C4" cell as category data
worksheet.Cells("C4").PutValue("Y2")
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", True)
'Setting the data source for the category data of NSeries
Chart.NSeries.CategoryData = "C1:C4"
'Setting the display unit of value(Y) axis.
chart.ValueAxis.DisplayUnit = DisplayUnitType.Hundreds
Dim displayUnitLabel As DisplayUnitLabel = chart.ValueAxis.DisplayUnitLabel
'Setting the custom display unit label
displayUnitLabel.Text = "100"
'Saving the Excel file
workbook.Save("C:\\book1.xls")
Provides access to
[C#]
//Instantiate a Workbook object by calling its empty constructor
Workbook workbook = new Workbook("C:\\book1.xls");
//Retrieve a list of all custom document properties of the Excel file
DocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
//Accessng a custom document property by using the property index
DocumentProperty customProperty1 = customProperties[3];
//Accessng a custom document property by using the property name
DocumentProperty customProperty2 = customProperties["Owner"];
[VB.NET]
'Instantiate a Workbook object by calling its empty constructor
Dim workbook As Workbook = New Workbook("C:\\book1.xls")
'Retrieve a list of all custom document properties of the Excel file
Dim customProperties As DocumentPropertyCollection = workbook.Worksheets.CustomDocumentProperties
'Accessng a custom document property by using the property index
Dim customProperty1 As DocumentProperty = customProperties(3)
'Accessng a custom document property by using the property name
Dim customProperty2 As DocumentProperty = customProperties("Owner")
Returns null if a property with the specified name is not found.
The string names of the properties correspond to the names of the typed
properties available from
If you request a property that is not present in the document, but the name
of the property is recognized as a valid built-in name, a new
If you request a property that is not present in the document and the name is not recognized as a built-in name, a null is returned.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
If the document was never printed, this property will return DateTime.MinValue.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Aspose.Cells does not update this property when you modify the document.
Each
[C#]
//Instantiate a Workbook object
Workbook workbook = new Workbook("C:\\book1.xls");
//Retrieve a list of all custom document properties of the Excel file
CustomDocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
[VB.NET]
'Instantiate a Workbook object
Dim workbook As New Workbook("C:\book1.xls")
'Retrieve a list of all custom document properties of the Excel file
Dim customProperties As CustomDocumentPropertyCollection = workbook.Worksheets.CustomDocumentProperties
[C#]
//Instantiate a Workbook object
Workbook workbook = new Workbook("C:\\book1.xls");
//Retrieve a list of all custom document properties of the Excel file
DocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
//Accessng a custom document property by using the property index
DocumentProperty customProperty1 = customProperties[3];
//Accessng a custom document property by using the property name
DocumentProperty customProperty2 = customProperties["Owner"];
[VB.NET]
'Instantiate a Workbook object
Dim workbook As Workbook = New Workbook("C:\\book1.xls")
'Retrieve a list of all custom document properties of the Excel file
Dim customProperties As DocumentPropertyCollection = workbook.Worksheets.CustomDocumentProperties
'Accessng a custom document property by using the property index
Dim customProperty1 As DocumentProperty = customProperties(3)
'Accessng a custom document property by using the property name
Dim customProperty2 As DocumentProperty = customProperties("Owner")
Converts a number property using Object.ToString(). Converts a boolean property into "Y" or "N". Converts a date property into a short date string.
Throws an exception if the property type is not PropertyType.Date.
Throws an exception if the property type is not PropertyType.Boolean.
[C#]
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["a1"].PutValue(2);
cells["a2"].PutValue(5);
cells["a3"].PutValue(3);
cells["a4"].PutValue(6);
cells["b1"].PutValue(4);
cells["b2"].PutValue(3);
cells["b3"].PutValue(6);
cells["b4"].PutValue(7);
cells["C1"].PutValue("Q1");
cells["C2"].PutValue("Q2");
cells["C3"].PutValue("Y1");
cells["C4"].PutValue("Y2");
int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column, 11, 0, 27, 10);
Chart chart = excel.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:B4", true);
chart.NSeries.CategoryData = "C1:C4";
for(int i = 0; i < chart.NSeries.Count; i ++)
{
ASeries aseries = chart.NSeries[i];
aseries.YErrorBar.DisplayType = ErrorBarDisplayType.Minus;
aseries.YErrorBar.Type = ErrorBarType.FixedValue;
aseries.YErrorBar.Amount = 5;
}
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
cells("a1").PutValue(2)
cells("a2").PutValue(5)
cells("a3").PutValue(3)
cells("a4").PutValue(6)
cells("b1").PutValue(4)
cells("b2").PutValue(3)
cells("b3").PutValue(6)
cells("b4").PutValue(7)
cells("C1").PutValue("Q1")
cells("C2").PutValue("Q2")
cells("C3").PutValue("Y1")
cells("C4").PutValue("Y2")
Dim chartIndex As Integer = excel.Worksheets(0).Charts.Add(ChartType.Column,11,0,27,10)
Dim chart As Chart = excel.Worksheets(0).Charts(chartIndex)
chart.NSeries.Add("A1:B4", True)
chart.NSeries.CategoryData = "C1:C4"
Dim i As Integer
For i = 0 To chart.NSeries.Count - 1
Dim aseries As ASeries = chart.NSeries(i)
aseries.YErrorBar.DisplayType = ErrorBarDisplayType.Minus
aseries.YErrorBar.Type = ErrorBarType.FixedValue
aseries.YErrorBar.Amount = 5
Next
[C#]
//Applying a dotted line style on the lines of an NSeries
chart.NSeries[0].Border.Style = LineType.Dot;
chart.NSeries[0].Border.Color = Color.Red;
//Applying a triangular marker style on the data markers of an NSeries
chart.NSeries[0].MarkerStyle = ChartMarkerType.Triangle;
//Setting the weight of all lines in an NSeries to medium
chart.NSeries[1].Border.Weight = WeightType.MediumLine;
chart.NSeries[1].Border.Color = Color.Green;
[Visual Basic]
'Applying a dotted line style on the lines of an NSeries
chart.NSeries(0).Border.Style = LineType.Dot
chart.NSeries(0).Border.Color = Color.Red
'Applying a triangular marker style on the data markers of an NSeries
chart.NSeries(0).MarkerStyle = ChartMarkerType.Triangle
'Setting the weight of all lines in an NSeries to medium
chart.NSeries(1).Border.Weight = WeightType.MediumLine
[C#]
//Sets custom error bar type
aseries.YErrorBar.Type = ErrorBarType.InnerCustom;
aseries.YErrorBar.PlusValue = "=Sheet1!A1";
aseries.YErrorBar.MinusValue = "=Sheet1!A2";
[Visual Basic]
'Sets custom error bar type
aseries.YErrorBar.Type = ErrorBarType.InnerCustom
aseries.YErrorBar.PlusValue = "=Sheet1!A1"
aseries.YErrorBar.MinusValue = "=Sheet1!A2"
[C#]
//Open a file with external links
Workbook workbook = new Workbook("d:\\book1.xls");
//Get External Link
ExternalLink externalLink = workbook.Worksheets.ExternalLinks[0];
//Change External Link's Data Source
externalLink.DataSource = "d:\\link.xls";
[VB.NET]
'Open a file with external links
Dim workbook As New Workbook("d:\book1.xls")
'Get External Link
Dim externalLink As ExternalLink = workbook.Worksheets.ExternalLinks(0)
'Change External Link's Data Source
externalLink.DataSource = "d:\link.xls"
[C#]
//Open a file with external links
Workbook workbook = new Workbook("d:\\book1.xls");
//Change external link data source
workbook.Worksheets.ExternalLinks[0].DataSource = "d:\\link.xls";
[Visual Basic]
'Open a file with external links
Dim workbook As Workbook = New Workbook("d:\\book1.xls")
'Change external link data source
workbook.Worksheets.ExternalLinks(0).DataSource = "d:\\link.xls"
[C#]
//Instantiate the License class
Aspose.Cells.License license = new Aspose.Cells.License();
//Pass only the name of the license file embedded in the assembly
license.SetLicense("Aspose.Cells.lic");
//Instantiate the workbook object
Workbook workbook = new Workbook();
//Get cells collection
Cells cells = workbook.Worksheets[0].Cells;
//Put values in cells
cells["A1"].PutValue(1);
cells["A2"].PutValue(2);
cells["A3"].PutValue(3);
//get charts colletion
Charts charts = workbook.Worksheets[0].Charts;
//add a new chart
int index = charts.Add(ChartType.Column3DStacked, 5, 0, 15, 5);
//get the newly added chart
Chart chart = charts[index];
//set charts nseries
chart.NSeries.Add("A1:A3", true);
//Show data labels
chart.NSeries[0].DataLabels.IsValueShown = true;
//Get chart's floor
Floor floor = chart.Floor;
//set floor's border as red
floor.Border.Color = System.Drawing.Color.Red;
//set fill format
floor.FillFormat.SetPresetColorGradient(GradientPresetType.CalmWater, GradientStyleType.DiagonalDown, 2);
//save the file
workbook.Save(@"d:\dest.xls");
[VB.NET]
'Instantiate the License class
Dim license As New Aspose.Cells.License()
'Pass only the name of the license file embedded in the assembly
license.SetLicense("Aspose.Cells.lic")
'Instantiate the workbook object
Dim workbook As New Workbook()
'Get cells collection
Dim cells As Cells = workbook.Worksheets(0).Cells
'Put values in cells
cells("A1").PutValue(1)
cells("A2").PutValue(2)
cells("A3").PutValue(3)
'get charts colletion
Dim charts As Charts = workbook.Worksheets(0).Charts
'add a new chart
Dim index As Integer = charts.Add(ChartType.Column3DStacked, 5, 0, 15, 5)
'get the newly added chart
Dim chart As Chart = charts(index)
'set charts nseries
chart.NSeries.Add("A1:A3", True)
'Show data labels
chart.NSeries(0).DataLabels.IsValueShown = True
'Get chart's floor
Dim floor As Floor = chart.Floor
'set floor's border as red
floor.Border.Color = System.Drawing.Color.Red
'set fill format
floor.FillFormat.SetPresetColorGradient(GradientPresetType.CalmWater, GradientStyleType.DiagonalDown, 2)
'save the file
workbook.Save("d:\dest.xls")
[C#]
//Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
//Sets the conditional format range.
CllArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
//Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
//Adds condition.
int conditionIndex2 = 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("C:\\output.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
' Adds an empty conditional formatting
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditionCollection = sheet.ConditionalFormattings(index)
'Sets the conditional format range.
Dim ca As CellArea = New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
ca = New CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.AddArea(ca)
'Adds condition.
Dim conditionIndex As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100")
'Adds condition.
Dim conditionIndex2 As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100")
'Sets the background color.
Dim fc As FormatCondition = fcs(conditionIndex)
fc.Style.BackgroundColor = Color.Red
'Saving the Excel file
workbook.Save("C:\output.xls")
[C#]
//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
//Add a group box to the first worksheet.
Aspose.Cells.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(1, 0, 1, 0, 300, 250);
//Set the caption of the group box.
box.Text = "Age Groups";
box.Placement = PlacementType.FreeFloating;
//Make it 2-D box.
box.Shadow = false;
//Add a radio button.
Aspose.Cells.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110);
//Set its text string.
radio1.Text = "20-29";
//Set A1 cell as a linked cell for the radio button.
radio1.LinkedCell = "A1";
//Make the radio button 3-D.
radio1.Shadow = true;
//Set the foreground color of the radio button.
radio1.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio1.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio1.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio1.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio1.LineFormat.IsVisible = true;
//Make the fill format visible.
radio1.FillFormat.IsVisible = true;
//Add another radio button.
Aspose.Cells.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110);
//Set its text string.
radio2.Text = "30-39";
//Set A1 cell as a linked cell for the radio button.
radio2.LinkedCell = "A1";
//Make the radio button 3-D.
radio2.Shadow = true;
//Set the foreground color of the radio button.
radio2.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio2.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio2.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio2.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio2.LineFormat.IsVisible = true;
//Make the fill format visible.
radio2.FillFormat.IsVisible = true;
//Add another radio button.
Aspose.Cells.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110);
//Set its text string.
radio3.Text = "40-49";
//Set A1 cell as a linked cell for the radio button.
radio3.LinkedCell = "A1";
//Make the radio button 3-D.
radio3.Shadow = true;
//Set the foreground color of the radio button.
radio3.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio3.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio3.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio3.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio3.LineFormat.IsVisible = true;
//Make the fill format visible.
radio3.FillFormat.IsVisible = true;
//Get the shapes.
Aspose.Cells.Shape[] shapeobjects = new Aspose.Cells.Shape[] { box, radio1, radio2, radio3 };
//Group the shapes.
Aspose.Cells.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
//Save the excel file.
excelbook.Save("d:\\test\\groupshapes.xls");
[VB.NET]
'Instantiate a new Workbook.
Dim excelbook As Workbook = New Workbook()
'Add a group box to the first worksheet.
Dim box As Aspose.Cells.GroupBox = excelbook.Worksheets(0).Shapes.AddGroupBox(1, 0, 1, 0, 300, 250)
'Set the caption of the group box.
box.Text = "Age Groups"
box.Placement = PlacementType.FreeFloating
'Make it 2-D box.
box.Shadow = False
'Add a radio button.
Dim radio1 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(3, 0, 2, 0, 30, 110)
'Set its text string.
radio1.Text = "20-29"
'Set A1 cell as a linked cell for the radio button.
radio1.LinkedCell = "A1"
'Make the radio button 3-D.
radio1.Shadow = True
'Set the foreground color of the radio button.
radio1.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio1.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio1.LineFormat.Weight = 4
'Set the line color of the radio button.
radio1.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio1.LineFormat.IsVisible = True
'Make the fill format visible.
radio1.FillFormat.IsVisible = True
'Add another radio button.
Dim radio2 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(6, 0, 2, 0, 30, 110)
'Set its text string.
radio2.Text = "30-39"
'Set A1 cell as a linked cell for the radio button.
radio2.LinkedCell = "A1"
'Make the radio button 3-D.
radio2.Shadow = True
'Set the foreground color of the radio button.
radio2.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio2.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio2.LineFormat.Weight = 4
'Set the line color of the radio button.
radio2.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio2.LineFormat.IsVisible = True
'Make the fill format visible.
radio2.FillFormat.IsVisible = True
'Add another radio button.
Dim radio3 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(9, 0, 2, 0, 30, 110)
'Set its text string.
radio3.Text = "40-49"
'Set A1 cell as a linked cell for the radio button.
radio3.LinkedCell = "A1"
'Make the radio button 3-D.
radio3.Shadow = True
'Set the foreground color of the radio button.
radio3.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio3.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio3.LineFormat.Weight = 4
'Set the line color of the radio button.
radio3.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio3.LineFormat.IsVisible = True
'Make the fill format visible.
radio3.FillFormat.IsVisible = True
'Get the shapes.
Dim shapeobjects() As Aspose.Cells.Shape = New Aspose.Cells.Shape() {box, radio1, radio2, radio3}
'Group the shapes.
Dim group As Aspose.Cells.GroupShape = excelbook.Worksheets(0).Shapes.Group(shapeobjects)
'Save the excel file.
excelbook.Save("d:\test\groupshapes.xls")
[C#]
//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
//Add a group box to the first worksheet.
Aspose.Cells.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(1, 0, 1, 0, 300, 250);
//Set the caption of the group box.
box.Text = "Age Groups";
box.Placement = PlacementType.FreeFloating;
//Make it 2-D box.
box.Shadow = false;
//Add a radio button.
Aspose.Cells.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110);
//Set its text string.
radio1.Text = "20-29";
//Set A1 cell as a linked cell for the radio button.
radio1.LinkedCell = "A1";
//Make the radio button 3-D.
radio1.Shadow = true;
//Set the foreground color of the radio button.
radio1.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio1.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio1.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio1.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio1.LineFormat.IsVisible = true;
//Make the fill format visible.
radio1.FillFormat.IsVisible = true;
//Add another radio button.
Aspose.Cells.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110);
//Set its text string.
radio2.Text = "30-39";
//Set A1 cell as a linked cell for the radio button.
radio2.LinkedCell = "A1";
//Make the radio button 3-D.
radio2.Shadow = true;
//Set the foreground color of the radio button.
radio2.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio2.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio2.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio2.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio2.LineFormat.IsVisible = true;
//Make the fill format visible.
radio2.FillFormat.IsVisible = true;
//Add another radio button.
Aspose.Cells.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110);
//Set its text string.
radio3.Text = "40-49";
//Set A1 cell as a linked cell for the radio button.
radio3.LinkedCell = "A1";
//Make the radio button 3-D.
radio3.Shadow = true;
//Set the foreground color of the radio button.
radio3.FillFormat.ForeColor = Color.LightGreen;
//Set the line style of the radio button.
radio3.LineFormat.Style = MsoLineStyle.ThickThin;
//Set the weight of the radio button.
radio3.LineFormat.Weight = 4;
//Set the line color of the radio button.
radio3.LineFormat.ForeColor = Color.Blue;
//Set the dash style of the radio button.
radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Make the line format visible.
radio3.LineFormat.IsVisible = true;
//Make the fill format visible.
radio3.FillFormat.IsVisible = true;
//Get the shapes.
Aspose.Cells.Shape[] shapeobjects = new Aspose.Cells.Shape[] { box, radio1, radio2, radio3 };
//Group the shapes.
Aspose.Cells.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
//Save the excel file.
excelbook.Save("d:\\test\\groupshapes.xls");
[VB.NET]
'Instantiate a new Workbook.
Dim excelbook As Workbook = New Workbook()
'Add a group box to the first worksheet.
Dim box As Aspose.Cells.GroupBox = excelbook.Worksheets(0).Shapes.AddGroupBox(1, 0, 1, 0, 300, 250)
'Set the caption of the group box.
box.Text = "Age Groups"
box.Placement = PlacementType.FreeFloating
'Make it 2-D box.
box.Shadow = False
'Add a radio button.
Dim radio1 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(3, 0, 2, 0, 30, 110)
'Set its text string.
radio1.Text = "20-29"
'Set A1 cell as a linked cell for the radio button.
radio1.LinkedCell = "A1"
'Make the radio button 3-D.
radio1.Shadow = True
'Set the foreground color of the radio button.
radio1.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio1.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio1.LineFormat.Weight = 4
'Set the line color of the radio button.
radio1.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio1.LineFormat.IsVisible = True
'Make the fill format visible.
radio1.FillFormat.IsVisible = True
'Add another radio button.
Dim radio2 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(6, 0, 2, 0, 30, 110)
'Set its text string.
radio2.Text = "30-39"
'Set A1 cell as a linked cell for the radio button.
radio2.LinkedCell = "A1"
'Make the radio button 3-D.
radio2.Shadow = True
'Set the foreground color of the radio button.
radio2.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio2.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio2.LineFormat.Weight = 4
'Set the line color of the radio button.
radio2.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio2.LineFormat.IsVisible = True
'Make the fill format visible.
radio2.FillFormat.IsVisible = True
'Add another radio button.
Dim radio3 As Aspose.Cells.RadioButton = excelbook.Worksheets(0).Shapes.AddRadioButton(9, 0, 2, 0, 30, 110)
'Set its text string.
radio3.Text = "40-49"
'Set A1 cell as a linked cell for the radio button.
radio3.LinkedCell = "A1"
'Make the radio button 3-D.
radio3.Shadow = True
'Set the foreground color of the radio button.
radio3.FillFormat.ForeColor = Color.LightGreen
'Set the line style of the radio button.
radio3.LineFormat.Style = MsoLineStyle.ThickThin
'Set the weight of the radio button.
radio3.LineFormat.Weight = 4
'Set the line color of the radio button.
radio3.LineFormat.ForeColor = Color.Blue
'Set the dash style of the radio button.
radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Make the line format visible.
radio3.LineFormat.IsVisible = True
'Make the fill format visible.
radio3.FillFormat.IsVisible = True
'Get the shapes.
Dim shapeobjects() As Aspose.Cells.Shape = New Aspose.Cells.Shape() {box, radio1, radio2, radio3}
'Group the shapes.
Dim group As Aspose.Cells.GroupShape = excelbook.Worksheets(0).Shapes.Group(shapeobjects)
'Save the excel file.
excelbook.Save("d:\test\groupshapes.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
//Add a page break at cell Y30
int Index = worksheet.HorizontalPageBreaks.Add("Y30");
//get the newly added horizontal page break
HorizontalPageBreak hPageBreak = worksheet.HorizontalPageBreaks[Index];
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Add a page break at cell Y30
Dim Index As Integer = worksheet.HorizontalPageBreaks.Add("Y30")
'get the newly added horizontal page break
Dim hPageBreak As HorizontalPageBreak = worksheet.HorizontalPageBreaks(Index)
[C#]
//Add a pagebreak at G5
excel.Worksheets[0].HorizontalPageBreaks.Add("G5");
excel.Worksheets[0].VerticalPageBreaks.Add("G5");
[VB]
'Add a pagebreak at G5
excel.Worksheets(0).HorizontalPageBreaks.Add("G5")
excel.Worksheets(0).VerticalPageBreaks.Add("G5")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
//Adding a hyperlink to a URL at "A1" cell
worksheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Workbook object
workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Adding a hyperlink to a URL at "A1" cell
worksheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com")
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
//Get Hyperlinks Collection
HyperlinkCollection hyperlinks = worksheet.Hyperlinks;
//Adding a hyperlink to a URL at "A1" cell
hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");
//Saving the Excel file
workbook.Save("D:\\book1.xls");
[VB.NET]
'Instantiating a Workbook object
Dim workbook As New Workbook()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Get Hyperlinks Collection
Dim hyperlinks As HyperlinkCollection = worksheet.Hyperlinks
'Adding a hyperlink to a URL at "A1" cell
hyperlinks.Add("A1", 1, 1, "http://www.aspose.com")
'Saving the Excel file
workbook.Save("D:\book1.xls")
[C#]
Worksheet worksheet = excel.Worksheets[0];
worksheet.Hyperlinks.Add("A4", 1, 1, "http://www.aspose.com");
worksheet.Hyperlinks.Add("A5", 1, 1, "c:\\book1.xls");
[Visual Basic]
Dim worksheet as Worksheet = excel.Worksheets(0)
worksheet.Hyperlinks.Add("A4", 1, 1, "http://www.aspose.com")
worksheet.Hyperlinks.Add("A5", 1, 1, "c:\\book1.xls")
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the workbook.
Worksheet sheet = workbook.Worksheets[0];
//Add a new label to the worksheet.
Aspose.Cells.Label label = sheet.Shapes.AddLabel(2, 0, 2, 0, 60, 120);
//Set the caption of the label.
label.Text = "This is a Label";
//Set the Placement Type, the way the
//label is attached to the cells.
label.Placement = PlacementType.FreeFloating;
//Set the fill color of the label.
label.FillFormat.ForeColor = Color.Yellow;
//Saves the file.
workbook.Save(@"d:\test\tstlabel.xls");
[VB.NET]
'Create a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet in the workbook.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Add a new label to the worksheet.
Dim label As Aspose.Cells.Label = sheet.Shapes.AddLabel(2, 0, 2, 0, 60, 120)
'Set the caption of the label.
label.Text = "This is a Label"
'Set the Placement Type, the way the
'label is attached to the cells.
label.Placement = PlacementType.FreeFloating
'Set the fill color of the label.
label.FillFormat.ForeColor = Color.Yellow
'Saves the file.
workbook.Save("d:\test\tstlabel.xls")
[C#]
//Set Legend's width and height
Legend legend = chart.Legend;
//Legend is at right side of chart by default.
//If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
//If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50;
//Set legend's position
legend.Position = LegendPositionType.Left;
[Visual Basic]
'Set Legend's width and height
Dim legend as Legend = chart.Legend
'Legend is at right side of chart by default.
'If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
'If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.Y = 1500
legend.Width = 50
legend.Height = 50
'Set legend's position
legend.Position = LegendPositionType.Left
[C#]
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the book.
Worksheet worksheet = workbook.Worksheets[0];
//Add a new line to the worksheet.
Aspose.Cells.LineShape line1 = worksheet.Shapes.AddLine(5, 0, 1, 0, 0, 250);
//Set the line dash style
line1.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Set the placement.
line1.Placement = PlacementType.FreeFloating;
//Add another line to the worksheet.
Aspose.Cells.LineShape line2 = worksheet.Shapes.AddLine(7, 0, 1, 0, 85, 250);
//Set the line dash style.
line2.LineFormat.DashStyle = MsoLineDashStyle.DashLongDash;
//Set the weight of the line.
line2.LineFormat.Weight = 4;
//Set the placement.
line2.Placement = PlacementType.FreeFloating;
//Add the third line to the worksheet.
Aspose.Cells.LineShape line3 = worksheet.Shapes.AddLine(13, 0, 1, 0, 0, 250);
//Set the line dash style
line3.LineFormat.DashStyle = MsoLineDashStyle.Solid;
//Set the placement.
line3.Placement = PlacementType.FreeFloating;
//Make the gridlines invisible in the first worksheet.
workbook.Worksheets[0].IsGridlinesVisible = false;
//Save the excel file.
workbook.Save("d:\\test\\tstlines.xls");
[VB.NET]
'Instantiate a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet in the book.
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Add a new line to the worksheet.
Dim line1 As Aspose.Cells.LineShape = worksheet.Shapes.AddLine(5, 0, 1, 0, 0, 250)
'Set the line dash style
line1.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Set the placement.
line1.Placement = PlacementType.FreeFloating
'Add another line to the worksheet.
Dim line2 As Aspose.Cells.LineShape = worksheet.Shapes.AddLine(7, 0, 1, 0, 85, 250)
'Set the line dash style.
line2.LineFormat.DashStyle = MsoLineDashStyle.DashLongDash
'Set the weight of the line.
line2.LineFormat.Weight = 4
'Set the placement.
line2.Placement = PlacementType.FreeFloating
'Add the third line to the worksheet.
Dim line3 As Aspose.Cells.LineShape = worksheet.Shapes.AddLine(13, 0, 1, 0, 0, 250)
'Set the line dash style
line3.LineFormat.DashStyle = MsoLineDashStyle.Solid
'Set the placement.
line3.Placement = PlacementType.FreeFloating
'Make the gridlines invisible in the first worksheet.
workbook.Worksheets(0).IsGridlinesVisible = False
'Save the excel file.
workbook.Save("d:\test\tstlines.xls")
[C#]
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Get the worksheet cells collection.
Cells cells = sheet.Cells;
//Input a value.
cells["B3"].PutValue("Choose Dept:");
//Set it bold.
cells["B3"].Style.Font.IsBold = true;
//Input some values that denote the input range
//for the list box.
cells["A2"].PutValue("Sales");
cells["A3"].PutValue("Finance");
cells["A4"].PutValue("MIS");
cells["A5"].PutValue("R&D");
cells["A6"].PutValue("Marketing");
cells["A7"].PutValue("HRA");
//Add a new list box.
ListBox listBox = sheet.Shapes.AddListBox(2, 0, 3, 0, 122, 100);
//Set the placement type.
listBox.Placement = PlacementType.FreeFloating;
//Set the linked cell.
listBox.LinkedCell = "A1";
//Set the input range.
listBox.InputRange = "A2:A7";
//Set the selection tyle.
listBox.SelectionType = SelectionType.Single;
//Set the list box with 3-D shading.
listBox.Shadow = true;
//Saves the file.
workbook.Save(@"d:\test\tstlistbox.xls");
[VB.NET]
'Create a new Workbook.
Dim workbook As Aspose.Cells.Workbook = New Aspose.Cells.Workbook()
'Get the first worksheet.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Get the worksheet cells collection.
Dim cells As Cells = sheet.Cells
'Input a value.
cells("B3").PutValue("Choose Dept:")
'Set it bold.
cells("B3").Style.Font.IsBold = True
'Input some values that denote the input range
'for the list box.
cells("A2").PutValue("Sales")
cells("A3").PutValue("Finance")
cells("A4").PutValue("MIS")
cells("A5").PutValue("R&D")
cells("A6").PutValue("Marketing")
cells("A7").PutValue("HRA")
'Add a new list box.
Dim listBox As Aspose.Cells.ListBox = sheet.Shapes.AddListBox(2, 0, 3, 0, 122, 100)
'Set the placement type.
listBox.Placement = PlacementType.FreeFloating
'Set the linked cell.
listBox.LinkedCell = "A1"
'Set the input range.
listBox.InputRange = "A2:A7"
'Set the selection tyle.
listBox.SelectionType = SelectionType.Single
'Set the list box with 3-D shading.
listBox.Shadow = True
'Saves the file.
workbook.Save("d:\test\tstlistbox.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Shapes shapes = workbook.Worksheets[0].Shapes;
shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1, "Aspose", "Arial", 30, false, false, 0, 0, 0, 0, 100, 200);
TextEffectFormat textEffectFormat = shapes[0].TextEffect;
textEffectFormat.SetTextEffect(MsoPresetTextEffect.TextEffect10);
workbook.Save("C:\\Book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
Dim shapes As Shapes = workbook.Worksheets(0).Shapes
shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1, "Aspose", "Arial", 30, false, false, 0, 0, 0, 0, 100, 200)
Dim textEffectFormat As TextEffectFormat = shapes(0).TextEffect
TextEffectFormat.SetTextEffect(MsoPresetTextEffect.TextEffect10)
workbook.Save("C:\\Book1.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Creating a named range
Range range = worksheet.Cells.CreateRange("B4", "G14");
//Setting the name of the named range
range.Name = "TestRange";
//Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("C:\\output.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Creating a named range
Dim range As Range = worksheet.Cells.CreateRange("B4", "G14")
'Setting the name of the named range
range.Name = "TestRange"
'Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("C:\\output.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "A4" cell
worksheet.Cells["A4"].PutValue(200);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a sample value to "B4" cell
worksheet.Cells["B4"].PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.Cells["C1"].PutValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.Cells["C2"].PutValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.Cells["C3"].PutValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.Cells["C4"].PutValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4";
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Integer = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "A4" cell
worksheet.Cells("A4").PutValue(200)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a sample value to "B4" cell
worksheet.Cells("B4").PutValue(40)
'Adding a sample value to "C1" cell as category data
worksheet.Cells("C1").PutValue("Q1")
'Adding a sample value to "C2" cell as category data
worksheet.Cells("C2").PutValue("Q2")
'Adding a sample value to "C3" cell as category data
worksheet.Cells("C3").PutValue("Y1")
'Adding a sample value to "C4" cell as category data
worksheet.Cells("C4").PutValue("Y2")
'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", True)
'Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4"
'Saving the Excel file
workbook.Save("C:\book1.xls")
[C#]
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Define a string variable to store the image path.
string ImageUrl = @"C:\school.jpg";
//Get the picture into the streams.
FileStream fs = File.OpenRead(ImageUrl);
//Define a byte array.
byte[] imageData = new Byte[fs.Length];
//Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length);
//Close the stream.
fs.Close();
//Get an excel file path in a variable.
string path = @"C:\Book1.xls";
//Get the file into the streams.
fs = File.OpenRead(path);
//Define an array of bytes.
byte[] objectData = new Byte[fs.Length];
//Store the file from streams.
fs.Read(objectData, 0, objectData.Length);
//Close the stream.
fs.Close();
//Add an Ole object into the worksheet with the image
//shown in MS Excel.
sheet.OleObjects.Add(14, 3, 200, 220, imageData);
//Set embedded ole object data.
sheet.OleObjects[0].ObjectData = objectData;
//Save the excel file
workbook.Save(@"C:\oleobjects.xls");
[Visual Basic]
'Instantiate a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Define a string variable to store the image path.
Dim ImageUrl As String = @"C:\school.jpg"
'Get the picture into the streams.
Dim fs As FileStream = File.OpenRead(ImageUrl)
'Define a byte array.
Dim imageData(fs.Length) As Byte
'Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length)
'Close the stream.
fs.Close()
'Get an excel file path in a variable.
Dim path As String = @"C:\Book1.xls"
'Get the file into the streams.
fs = File.OpenRead(path)
'Define an array of bytes.
Dim objectData(fs.Length) As Byte
'Store the file from streams.
fs.Read(objectData, 0, objectData.Length)
'Close the stream.
fs.Close()
'Add an Ole object into the worksheet with the image
'shown in MS Excel.
sheet.OleObjects.Add(14, 3, 200, 220, imageData)
'Set embedded ole object data.
sheet.OleObjects(0).ObjectData = objectData
'Save the excel file
workbook.Save("C:\oleobjects.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a picture at the location of a cell whose row and column indices
//are 5 in the worksheet. It is "F6" cell
worksheet.Pictures.Add(5, 5, "C:\\image.gif");
//Saving the Excel file
workbook.Save(saveFileDialog1.FileName, SaveFormat.Excel97To2003);
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Workbook object
Dim sheetIndex As Integer = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a picture at the location of a cell whose row and column indices
'are 5 in the worksheet. It is "F6" cell
worksheet.Pictures.Add(5, 5, "C:\image.gif")
'Saving the Excel file
workbook.Save("C:\book1.xls", SaveFormat.Excel97To2003)
[C#]
//Allowing users to select locked cells of the worksheet
worksheet.Protection.AllowSelectingLockedCell = true;
//Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = true;
[Visual Basic]
'Allowing users to select locked cells of the worksheet
worksheet.Protection.AllowSelectingLockedCell = True
'Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = True
[C#]
Cell cell = excel.Worksheets[0].Cells["A1"];
Style style = cell.GetStyle();
style.Font.Name = "Times New Roman";
style.Font.Color = Color.Blue;
cell.SetStyle(style);
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
You can set 255 or value ranged from -90 to 90.Value | Type | Format String |
0 | General | General |
1 | Decimal | 0 |
2 | Decimal | 0.00 |
3 | Decimal | #,##0 |
4 | Decimal | #,##0.00 |
5 | Currency | $#,##0_);($#,##0) |
6 | Currency | $#,##0_);[Red]($#,##0) |
7 | Currency | $#,##0.00_);($#,##0.00) |
8 | Currency | $#,##0.00_);[Red]($#,##0.00) |
9 | Percentage | 0% |
10 | Percentage | 0.00% |
11 | Scientific | 0.00E+00 |
12 | Fraction | # ?/? |
13 | Fraction | # ??/?? |
14 | Date | m/d/yyyy |
15 | Date | d-mmm-yy |
16 | Date | d-mmm |
17 | Date | mmm-yy |
18 | Time | h:mm AM/PM |
19 | Time | h:mm:ss AM/PM |
20 | Time | h:mm |
21 | Time | h:mm:ss |
22 | Time | m/d/yyyy h:mm |
37 | Accounting | #,##0_);(#,##0) |
38 | Accounting | #,##0_);[Red](#,##0) |
39 | Accounting | #,##0.00_);(#,##0.00) |
40 | Accounting | #,##0.00_);[Red](#,##0.00) |
41 | Accounting | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) |
42 | Currency | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) |
43 | Accounting | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) |
44 | Currency | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) |
45 | Time | mm:ss |
46 | Time | [h]:mm:ss |
47 | Time | mm:ss.0 |
48 | Scientific | ##0.0E+0 |
49 | Text | @ |
[C#]
Workbook workbook = new Workbook();
Style firstColumnStyle = workbook.CreateStyle();
firstColumnStyle.Pattern = BackgroundType.Solid;
firstColumnStyle.BackgroundColor = System.Drawing.Color.Red;
Style lastColumnStyle = workbook.CreateStyle();
lastColumnStyle.Font.IsBold = true;
lastColumnStyle.Pattern = BackgroundType.Solid;
lastColumnStyle.BackgroundColor = System.Drawing.Color.Red;
string tableStyleName = "Custom1";
TableStyleCollection tableStyles = workbook.Worksheets.TableStyles;
int index1 = tableStyles.AddTableStyle(tableStyleName);
TableStyle tableStyle = tableStyles[index1];
TableStyleElementCollection elements = tableStyle.TableStyleElements;
index1 = elements.Add(TableStyleElementType.FirstColumn);
TableStyleElement element = elements[index1];
element.SetElementStyle(firstColumnStyle);
index1 = elements.Add(TableStyleElementType.LastColumn);
element = elements[index1];
element.SetElementStyle(lastColumnStyle);
Cells cells = workbook.Worksheets[0].Cells;
for (int i = 0; i <5; i++)
{
cells[0, i].PutValue(CellsHelper.ColumnIndexToName(i));
}
for (int row = 1; row <10; row++)
{
for (int column = 0; column <5; column++)
{
cells[row, column].PutValue(row * column);
}
}
ListObjectCollection tables = workbook.Worksheets[0].ListObjects;
int index = tables.Add(0, 0, 9, 4, true);
ListObject table = tables[0];
table.ShowTableStyleFirstColumn = true;
table.ShowTableStyleLastColumn = true;
table.TableStyleName = tableStyleName;
workbook.Save(@"C:\Book1.xlsx");
[Visual Basic]
Dim workbook As Workbook = New Workbook()
Dim firstColumnStyle As Style = workbook.CreateStyle()
firstColumnStyle.Pattern = BackgroundType.Solid
firstColumnStyle.BackgroundColor = System.Drawing.Color.Red
Dim lastColumnStyle As Style = workbook.CreateStyle()
lastColumnStyle.Font.IsBold = True
lastColumnStyle.Pattern = BackgroundType.Solid
lastColumnStyle.BackgroundColor = System.Drawing.Color.Red
Dim tableStyleName As String = "Custom1"
Dim tableStyles As TableStyleCollection = workbook.Worksheets.TableStyles
Dim index1 As Int32 = tableStyles.AddTableStyle(tableStyleName)
Dim tableStyle As TableStyle = tableStyles(index1)
Dim elements As TableStyleElementCollection = tableStyle.TableStyleElements
index1 = elements.Add(TableStyleElementType.FirstColumn)
Dim element As TableStyleElement = elements(index1)
element.SetElementStyle(firstColumnStyle)
index1 = elements.Add(TableStyleElementType.LastColumn)
element = elements(index1)
element.SetElementStyle(lastColumnStyle)
Dim cells As Cells = workbook.Worksheets(0).Cells
For i As Int32 = 0 To 4
cells(0, i).PutValue(CellsHelper.ColumnIndexToName(i))
Next
For row As Int32 = 1 To 9
For column As Int32 = 0 To 4
cells(row, column).PutValue(row * column)
Next
Next
Dim tables As ListObjectCollection = workbook.Worksheets(0).ListObjects
Dim index As Int32 = tables.Add(0, 0, 9, 4, True)
Dim table As ListObject = tables(0)
table.ShowTableStyleFirstColumn = True
table.ShowTableStyleLastColumn = True
table.TableStyleName = tableStyleName
workbook.Save("C:\Book1.xlsx")
[C#]
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the book.
Worksheet worksheet = workbook.Worksheets[0];
//Add a new textbox to the collection.
int textboxIndex = worksheet.TextBoxes.Add(2, 1, 160, 200);
//Get the textbox object.
Aspose.Cells.TextBox textbox0 = worksheet.TextBoxes[textboxIndex];
//Fill the text.
textbox0.Text = "ASPOSE______The .NET and JAVA Component Publisher!";
//Get the textbox text frame.
MsoTextFrame textframe0 = textbox0.TextFrame;
//Set the textbox to adjust it according to its contents.
textframe0.AutoSize = true;
//Set the placement.
textbox0.Placement = PlacementType.FreeFloating;
//Set the font color.
textbox0.Font.Color = Color.Blue;
//Set the font to bold.
textbox0.Font.IsBold = true;
//Set the font size.
textbox0.Font.Size = 14;
//Set font attribute to italic.
textbox0.Font.IsItalic = true;
//Add a hyperlink to the textbox.
textbox0.AddHyperlink("http://www.aspose.com/");
//Get the filformat of the textbox.
MsoFillFormat fillformat = textbox0.FillFormat;
//Set the fillcolor.
fillformat.ForeColor = Color.Silver;
//Get the lineformat type of the textbox.
MsoLineFormat lineformat = textbox0.LineFormat;
//Set the line style.
lineformat.Style = MsoLineStyle.ThinThick;
//Set the line weight.
lineformat.Weight = 6;
//Set the dash style to squaredot.
lineformat.DashStyle = MsoLineDashStyle.SquareDot;
//Add another textbox.
textboxIndex = worksheet.TextBoxes.Add(15, 4, 85, 120);
//Get the second textbox.
Aspose.Cells.TextBox textbox1 = worksheet.TextBoxes[textboxIndex];
//Input some text to it.
textbox1.Text = "This is another simple text box";
//Set the placement type as the textbox will move and
//resize with cells.
textbox1.Placement = PlacementType.MoveAndSize;
//Save the excel file.
workbook.Save("C:\\tsttextboxes.xls");
[Visual Basic]
'Instantiate a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet in the book.
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Add a new textbox to the collection.
Dim textboxIndex As Integer = worksheet.TextBoxes.Add(2, 1, 160, 200)
'Get the textbox object.
Dim textbox0 As Aspose.Cells.TextBox = worksheet.TextBoxes(textboxIndex)
'Fill the text.
textbox0.Text = "ASPOSE______The .NET and JAVA Component Publisher!"
'Get the textbox text frame.
Dim textframe0 As MsoTextFrame = textbox0.TextFrame
'Set the textbox to adjust it according to its contents.
textframe0.AutoSize = True
'Set the placement.
textbox0.Placement = PlacementType.FreeFloating
'Set the font color.
textbox0.Font.Color = Color.Blue
'Set the font to bold.
textbox0.Font.IsBold = True
'Set the font size.
textbox0.Font.Size = 14
'Set font attribute to italic.
textbox0.Font.IsItalic = True
'Add a hyperlink to the textbox.
textbox0.AddHyperlink("http://www.aspose.com/")
'Get the filformat of the textbox.
Dim fillformat As MsoFillFormat = textbox0.FillFormat
'Set the fillcolor.
fillformat.ForeColor = Color.Silver
'Get the lineformat type of the textbox.
Dim lineformat As MsoLineFormat = textbox0.LineFormat
'Set the line style.
lineformat.Style = MsoLineStyle.ThinThick
'Set the line weight.
lineformat.Weight = 6
'Set the dash style to squaredot.
lineformat.DashStyle = MsoLineDashStyle.SquareDot
'Add another textbox.
textboxIndex = worksheet.TextBoxes.Add(15, 4, 85, 120)
'Get the second textbox.
Dim textbox1 As Aspose.Cells.TextBox = worksheet.TextBoxes(textboxIndex)
'Input some text to it.
textbox1.Text = "This is another simple text box"
'Set the placement type as the textbox will move and
'resize with cells.
textbox1.Placement = PlacementType.MoveAndSize
'Save the excel file.
workbook.Save("C:\tsttextboxes.xls")
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["A1"].PutValue("Hello World");
Style style = cells["A1"].GetStyle();
//Set ThemeColorType.Text2 color type with 40% lighten as the font color.
style.Font.ThemeColor = new ThemeColor(ThemeColorType.Text2, 0.4);
style.Pattern = BackgroundType.Solid;
//Set ThemeColorType.Background2 color type with 75% darken as the foreground color
style.ForegroundThemeColor = new ThemeColor(ThemeColorType.Background2, -0.75);
cells["A1"].SetStyle(style);
//Saving the Excel file
workbook.Save("C:\\book1.xlsx");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
cells("A1").PutValue("Hello World")
'Get the cell style
Dim style As Style = cells("A1").GetStyle()
'Set ThemeColorType.Text2 color type with 40% lighten as the font color.
Style.Font.ThemeColor = New ThemeColor(ThemeColorType.Text2, 0.4)
Style.Pattern = BackgroundType.Solid
'Set ThemeColorType.Background2 color type with 75% darken as the foreground color
style.ForegroundThemeColor = New ThemeColor(ThemeColorType.Background2, -0.75)
'Set the cell style
cells("A1").SetStyle(style)
'Saving the Excel file
Workbook.Save("C:\\book1.xlsx")
[C#]
//Setting the title of a chart
chart.Title.Text = "Title";
//Setting the font color of the chart title to blue
chart.Title.Font.Color = Color.Blue;
//Setting the title of category axis of the chart
chart.CategoryAxis.Title.Text = "Category";
//Setting the title of value axis of the chart
chart.ValueAxis.Title.Text = "Value";
[Visual Basic]
'Setting the title of a chart
chart.Title.Text = "Title"
'Setting the font color of the chart title to blue
chart.Title.Font.Color = Color.Blue
'Setting the title of category axis of the chart
chart.CategoryAxis.Title.Text = "Category"
'Setting the title of value axis of the chart
chart.ValueAxis.Title.Text = "Value"
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "A4" cell
worksheet.Cells["A4"].PutValue(200);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a sample value to "B4" cell
worksheet.Cells["B4"].PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.Cells["C1"].PutValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.Cells["C2"].PutValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.Cells["C3"].PutValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.Cells["C4"].PutValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4";
//adding a linear trendline
int index = chart.NSeries[0].TrendLines.Add(TrendlineType.Linear);
Trendline trendline = chart.NSeries[0].TrendLines[index];
//Setting the custom name of the trendline.
trendline.Name = "Linear";
//Displaying the equation on chart
trendline.DisplayEquation = true;
//Displaying the R-Squared value on chart
trendline.DisplayRSquared = true;
//Saving the Excel file
workbook.Save("C:\\book1.xls");
[Visual Basic]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "A4" cell
worksheet.Cells("A4").PutValue(200)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a sample value to "B4" cell
worksheet.Cells("B4").PutValue(40)
'Adding a sample value to "C1" cell as category data
worksheet.Cells("C1").PutValue("Q1")
'Adding a sample value to "C2" cell as category data
worksheet.Cells("C2").PutValue("Q2")
'Adding a sample value to "C3" cell as category data
worksheet.Cells("C3").PutValue("Y1")
'Adding a sample value to "C4" cell as category data
worksheet.Cells("C4").PutValue("Y2")
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("A1:B4", True)
'Setting the data source for the category data of NSeries
Chart.NSeries.CategoryData = "C1:C4"
'adding a linear trendline
Dim index As Int32 = chart.NSeries(0).TrendLines.Add(TrendlineType.Linear)
Dim trendline As Trendline = chart.NSeries(0).TrendLines(index)
'Setting the custom name of the trendline.
trendline.Name = "Linear"
'Displaying the equation on chart
trendline.DisplayEquation = True
'Displaying the R-Squared value on chart
trendline.DisplayRSquared = True
'Saving the Excel file
workbook.Save("C:\\book1.xls")
[C#]
int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column, 3, 3, 15, 10);
Chart chart = excel.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:a3", true);
chart.NSeries[0].TrendLines.Add(TrendlineType.Linear, "MyTrendLine");
Trendline line = chart.NSeries[0].TrendLines[0];
line.DisplayEquation = true;
line.DisplayRSquared = true;
line.Color = Color.Red;
[Visual Basic]
Dim chartIndex As Integer = excel.Worksheets(0).Charts.Add(ChartType.Column,3,3,15,10)
Dim chart As Chart = excel.Worksheets(0).Charts(chartIndex)
chart.NSeries.Add("A1:a3", True)
chart.NSeries(0).TrendLines.Add(TrendlineType.Linear, "MyTrendLine")
Dim line As Trendline = chart.NSeries(0).TrendLines(0)
line.DisplayEquation = True
line.DisplayRSquared = True
line.Color = Color.Red
[C#]
//Add a pagebreak at G5
excel.Worksheets[0].HorizontalPageBreaks.Add("G5");
excel.Worksheets[0].VerticalPageBreaks.Add("G5");
[VB]
'Add a pagebreak at G5
excel.Worksheets(0).HorizontalPageBreaks.Add("G5")
excel.Worksheets(0).VerticalPageBreaks.Add("G5")