[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;
}
}
}
range.Name = "Sheet1!MyRange";
[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")
{
m_LoadDataFilterOptions = Aspose.Cells.LoadDataFilterOptions.All;
}
else
{
m_LoadDataFilterOptions = Aspose.Cells.LoadDataFilterOptions.None;
}
}
}
[C#]
Metered matered = new Metered();
matered.SetMeteredKey("PublicKey", "PrivateKey");
[Visual Basic]
Dim matered As Metered = New Metered
matered.SetMeteredKey("PublicKey", "PrivateKey")
Metered matered = new Metered();
matered.setMeteredKey("PublicKey", "PrivateKey");
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");
Provides access to
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.
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.
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 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.
[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;
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();
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();
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#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Get Conditional Formattings
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 Formattings
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#]
//Open a designer file
string designerFile = MapPath("Designer") + "\\designer.xls";
Workbook workbook = new Workbook(designerFile);
//Set scroll bars
workbook.IsHScrollBarVisible = false;
workbook.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)
File format is according to file extension.
After calling Save method, data in Workbook instance will be reset.
[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)
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¡¡ |
Now Workbook built-in functions are not supported in this method:
[A]
ASC
[B]
BAHTTEXT
[C]
CALL, CLEAN, CODE, CONVERT, CUBEKPIMEMBER, CUBEMEMBER, CUBEMEMBERPROPERTY, CUBERANKEDMEMBER, CUBESET, CUBESETCOUNT, CUBEVALUE
[E]
EUROCONVERT
[G]
GETPIVOTDATA
[I]
INFO
[J]
JIS
[P]
PHONETIC
[R]
REGISTER.ID, RTD
[S]
SQL.REQUEST
[Y]
YIELD, YIELDDISC
[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
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¡¡ |
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#]
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")
License 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")
License 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.
2. The current working directory of the java application.
3. The folder that contains the Aspose component JAR file.
4. The folder that contains the client's calling JAR file.
[C#]
License license = new License();
license.SetLicense("MyLicense.lic");
[Visual Basic]
Dim license As License = New License
license.SetLicense("MyLicense.lic")
License license = new License();
license.setLicense("MyLicense.lic");
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)
License license = new License();
license.setLicense(myStream);
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#]
//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")
[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.SearchNext = true;
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.SearchNext = True
findOptions.SeachOrderByRows = True
findOptions.LookInType = LookInType.Values
'Find the cell with 0 value
Dim cell As Cell = cells.Find(0, Nothing, findOptions)
[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#]
int styleIndex = workbook.Styles.Add();
Style style = workbook.Styles[styleIndex];
//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 styleIndex as Integer = workbook.Styles.Add()
Dim style as Style = workbook.Styles[styleIndex]
'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#]
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 excel = new Workbook();
Cells cells = excel.Worksheets[0];
cells["B6"].Formula = "=SUM(B2:B5, E1) + sheet2!A1";
[Visual Basic]
Dim excel As Workbook = New Workbook()
Dim cells As Cells = excel.Worksheets(0)
cells("B6").Formula = "=SUM(B2:B5, E1) + sheet2!A1"
[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()")
null,
Boolean,
DateTime,
Double,
Integer
String.
[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#]
//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 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#]
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();
//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")
[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.Styles[workbook.Styles.Add()];
//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)
'Add new Style to Workbook
Dim style As Style = workbook.Styles(workbook.Styles.Add())
'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")
[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.Styles[workbook.Styles.Add()];
//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.Styles(workbook.Styles.Add())
'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();
Worksheet sheet = workbook.Worksheets[0];
//Get Conditional Formattings
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 Formattings
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#]
//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#]
//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#]
//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"
[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#]
//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#]
//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")
1. Current Workbook object.
2. Current Worksheet object.
3. Current Cell object.
Others are custom function parameters text.
If a custom function name is not supported, please return a null reference.
[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#]
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"
[C#]
sheet.PageSetup.PrintTitleColumns = "$A:$A";
[Visula Basic]
sheet.PageSetup.PrintTitleColumns = "$A:$A"
[C#]
sheet.PageSetup.PrintTitleRows = "$1:$1";
[Visula Basic]
sheet.PageSetup.PrintTitleRows = "$1:$1"
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 exampe: &"Arial" |
&"<FontName>, <FontStyle>" | Font name and font style, for exampe: &"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 exampe(RED): &FF0000 |
&G | Image script |
0:Left Section.
1:Center Section
2:Right Section
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 exampe: &"Arial" |
&"<FontName>, <FontStyle>" | Font name and font style, for exampe: &"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
[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
range.Name = "Sheet1!MyRange";
[C#]
int styleIndex = excel.CreateStyle();
Style style = excel.Styles[styleIndex];
style.Font.Name = "Times New Roman";
style.Font.Color = Color.Blue;
for(int i = 0; i < 100; i ++)
{
excel.Worksheets[0].Cells[0, i].SetStyle(style);
}
//Second method
[C#]
Style style = excel.Worksheets[0].Cells["A1"].GetStyle();
style.Font.Name = "Times New Roman";
style.Font.Color = Color.Blue;
excel.Worksheets[0].Cells["A1"].SetStyle(style);
First method is a fast and efficient way to change several cell-formatting properties on multiple cells at the same time.
If you want to change a single cell's style properties, second method can be used.
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
You can set 255 or value ranged from -90 to 90.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+00 |
49 | Text | @ |
[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#]
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.AreaList.Add(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.AreaList.Add(area)
[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#]
// 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();
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 freezed position and the last two parameters specify the area freezed 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#]
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")