Knowledgebase (2311)
Children categories
As we know, when we add a comment in MS-Excel, there will be Author appended automatically by Excel program. In fact, there is not the Author property in the comment in MS-Excel, which is just a text with special bold font style, and you can edit, remove, and insert other strings. After adding a comment (e.g., Test comment1) by using Spire.XLS component, there is no author is written into excel file. Check the below picture:

How to add a comment with editable Author property by Spire.XLS component? Just like the comment in the following picture:

Download Spire.XLS for .NET and install it on your computer. Then create CreateComment(CellRange range,string text, string author=null) method to implement it. Firstly, add a comment for a specified range by calling the CellRange.AddComment() method. Then, if the author is specified, create a new font with bold style and apply the font to the author text.
The following is the code for the method:
static ExcelComment CreateComment(CellRange range,string text, string author=null)
{
ExcelComment comment= range.AddComment();
comment.Text = String.IsNullOrEmpty(author) ? text : author + ":\n" + text;
if (!String.IsNullOrEmpty(author))
{
ExcelFont font = range.Worksheet.Workbook.CreateFont();
font.FontName = "Tahoma";
font.KnownColor = ExcelColors.Black;
font.IsBold = true;
comment.RichText.SetFont(0, author.Length,font);
}
return comment;
}
Private Function CreateComment(ByVal range As CellRange, ByVal text As String, Optional ByVal author As String = Nothing) As ExcelComment
Dim comment As ExcelComment = range.AddComment()
comment.Text = If([String].IsNullOrEmpty(author), text, author & ":" & vbLf & text)
If Not [String].IsNullOrEmpty(author) Then
Dim font As ExcelFont = range.Worksheet.Workbook.CreateFont()
font.FontName = "Tahoma"
font.KnownColor = ExcelColors.Black
font.IsBold = True
comment.RichText.SetFont(0, author.Length, font)
End If
Return comment
End Function
Next, you can call the method to add comments with author to your excel file.
CellRange range = sheet.Range["A1"]; CreateComment(range, "Test comment2", "E-iceblue");
Dim range As CellRange = sheet.Range("A1")
CreateComment(range, "Test comment2", "E-iceblue")
Tables in Word documents allow users to organize data in a structured, readable format. However, at times you may find that some tables are outdated or no longer serve their intended purpose, making it necessary to remove them. In this article, you will learn how to remove tables from a Word document in C# using Spire.Doc for .NET.
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Remove a Specified Table in Word in C#
Spire.Doc for .NET provides the Section.Tables.RemoveAt(int index) method to delete a specified table in a Word document by index. The following are the detailed steps.
- Create a Document instance.
- Load a Word document using Document.LoadFromFile() method.
- Get a specified section using Document.Sections[] property.
- Delete a specified table by index using Section.Tables.RemoveAt() method.
- Save the result document using Document.SaveToFile() method.
- C#
using Spire.Doc;
namespace RemoveTable
{
class Program
{
static void Main(string[] args)
{
//Create a Document instance
Document doc = new Document();
//Load a Word document
doc.LoadFromFile("tables.docx");
//Get the first section in the document
Section sec = doc.Sections[0];
//Remove the first table in the section
sec.Tables.RemoveAt(0);
//Save the result document
doc.SaveToFile("RemoveATable.docx", FileFormat.Docx);
}
}
}

Remove All Tables in Word in C#
To delete all tables from a Word document, you need to iterate through all sections in the document, then iterate through all tables in each section and remove them through the Section.Tables.Remove() method. The following are the detailed steps.
- Create a Document instance.
- Load a Word document using Document.LoadFromFile() method.
- Iterate through all sections in the document.
- Iterate through all tables in each section.
- Delete the tables using Section.Tables.Remove() method.
- Save the result document using Document.SaveToFile() method.
- C#
using Spire.Doc;
namespace RemoveAllTable
{
class Program
{
static void Main(string[] args)
{
//Create a Document instance
Document doc = new Document();
//Load a Word document
doc.LoadFromFile("tables.docx");
//Iterate through all sections in the document
foreach (Section section in doc.Sections)
{
//Iterate through all tables in each section
foreach (Table table in section.Tables)
{
//Remove the tables
section.Tables.Remove(table);
}
}
//Save the result document
doc.SaveToFile("RemoveTables.docx", FileFormat.Docx);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
When the data in specific rows or columns are no longer needed, you can delete those rows or columns from your worksheet. In this article, you will learn how to delete rows and columns from Excel in C# and VB.NET using Spire.XLS for .NET library.
Install Spire.XLS for.NET
To begin with, you need to add the DLL files included in the Spire.XLS for.NET package as references in your .NET project. The DLLs files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Delete a Specific Row and Column from Excel in C# and VB.NET
The following are the steps to delete a specific row and column from an Excel worksheet:
- Create a Workbook instance.
- Load an Excel file using Workbook.LoadFromFile() method.
- Get the desired worksheet using Workbook.Worksheets[sheetIndex] property.
- Delete the desired row from the worksheet by its index (1-based) using Worksheet.DeleteRow(rowIndex) method.
- Delete the desired column from the worksheet by its index (1-based) using Worksheet.DeleteColumn(columnIndex) method.
- Save the result file using Workbook.SaveToFile() method.
- C#
- VB.NET
using Spire.Xls;
namespace DeleteRowAndColumn
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load an Excel file
workbook.LoadFromFile("Sample.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Delete the 9th row
sheet.DeleteRow(9);
//Delete the 3rd column
sheet.DeleteColumn(3);
//Save the result file
workbook.SaveToFile("DeleteRowAndColumn.xlsx", ExcelVersion.Version2016);
}
}
}

Delete Multiple Rows and Columns from Excel in C# and VB.NET
The following are the steps to delete multiple rows and columns from an Excel worksheet:
- Create a Workbook instance.
- Load an Excel file using Workbook.LoadFromFile() method.
- Get the desired worksheet using Workbook.Worksheets[sheetIndex] property.
- Delete the desired rows from the worksheet using Worksheet.DeleteRow(startRowIndex, rowCount) method.
- Delete the desired columns from the worksheet using Worksheet.DeleteColumn(startColumnIndex, columnCount) method.
- Save the result file using Workbook.SaveToFile() method.
- C#
- VB.NET
using Spire.Xls;
namespace DeleteMultipleRowsAndColumns
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load an Excel file
workbook.LoadFromFile(@"Sample.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Delete 3 rows from the worksheet starting from the 7th row
sheet.DeleteRow(7, 3);
//Delete 3 columns from the worksheet starting from the 3rd column
sheet.DeleteColumn(3, 3);
//Save the result file
workbook.SaveToFile("DeleteMultipleRowsAndColumns.xlsx", ExcelVersion.Version2016);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.