Knowledgebase (2330)
Children categories
If you created a pretty Excel table and now want to publish it online as a web page, the simplest way is to export it to an old good HTML file. However a problem may occur if you just simply transform image in Excel to HTML code with a relative link (URL). This way, your web page may no longer display properly on client machines since the image can't be reached through that URL on client-side. In this article, we’re going to resolve this issue by embedding image in HTML code when converting Excel to HTML.
Here is an Excel table with some images embedded in.

We're able to convert this Excel file to HTML by following below code snippet:
Step 1: Create a new instance of workbook.
Workbook book = new Workbook();
book.LoadFromFile("Book1.xlsx");
Step 2: Embed images into HTML code using Data URI scheme.
HTMLOptions options = new HTMLOptions(); options.ImageEmbedded = true;
Step 3: Save the worksheet to HTML.
book.Worksheets[0].SaveToHtml("sample.html", options);
System.Diagnostics.Process.Start("sample.html");
Output:

HTML Code:
Since the HTML code is too long to be displayed here, we have to present it by a screenshot.

Full C# Code:
using Spire.Xls;
using Spire.Xls.Core.Spreadsheet;
namespace CreateWorkbook
{
class Program
{
static void Main(string[] args)
{
// create Workbook instance and load file
Workbook book = new Workbook();
book.LoadFromFile("Book1.xlsx");
// embed image into html when converting
HTMLOptions options = new HTMLOptions();
options.ImageEmbedded = true;
// save the sheet to html
book.Worksheets[0].SaveToHtml("sample.html", options);
System.Diagnostics.Process.Start("sample.html");
}
}
}
Remove borderline of textbox in Excel chart in C#, VB.NET
2014-08-12 07:57:21 Written by AdministratorThere is an article in the tutorials which demonstrates how to insert textbox with contents in Excel. Sometime back, a user of Spire.XLS wanted to know if it is possible to remove the borderline of the textbox that has been inserted in Excel chart. Yes, of course. This article focuses on delivering a solution to this issue.
In the following section, we're going to create two textboxes in the same chart, one textbox is built with borderline, the other one without. Then we can learn how to remove borderline using Spire.XLS by comparison.
Code snippet for remove borderline of textbox:
Step 1: Create a new instance of workbook.
Workbook workbook = new Workbook(); workbook.Version=ExcelVersion.Version2010;
Step 2: Create a new worksheet named "Remove Borderline" and add a chart to the worksheet.
Worksheet sheet = workbook.Worksheets[0]; sheet.Name = "Remove Borderline"; Chart chart = sheet.Charts.Add();
Step 3: Create textbox1 in the chart and input text information.
XlsTextBoxShape textbox1 = chart.TextBoxes.AddTextBox(50, 50, 100, 500) as XlsTextBoxShape;
Step 4: Create textbox2 in the chart, input text information and remove borderline.
XlsTextBoxShape textbox = chart.TextBoxes.AddTextBox(500, 50, 100, 500) as XlsTextBoxShape; textbox.Text = "The solution without borderline"; textbox.Line.Weight = 0;
Step 5: Save and launch the file.
workbook.SaveToFile("Sample.xlsx", ExcelVersion.Version2010);
Process.Start("Sample.xlsx");
Result:

Full code:
using Spire.Xls;
using Spire.Xls.Core.Spreadsheet.Shapes;
using System.Diagnostics;
namespace RemoveBorderlineofTextbox
{
class Program
{
static void Main(string[] args)
{
// Create a new workbook
Workbook workbook = new Workbook();
workbook.Version = ExcelVersion.Version2010;
// Get the first worksheet and rename it
Worksheet sheet = workbook.Worksheets[0];
sheet.Name = "Remove Borderline";
// Add a chart to the worksheet
Chart chart = sheet.Charts.Add();
// Add the first text box (with visible border)
XlsTextBoxShape textbox1 = chart.TextBoxes.AddTextBox(50, 50, 100, 500) as XlsTextBoxShape ;
textbox1.Text = "The original with borderline";
// Add the second text box (border will be hidden)
XlsTextBoxShape textbox2 = chart.TextBoxes.AddTextBox(500, 50, 100, 500) as XlsTextBoxShape;
textbox2.Text = "The solution without borderline";
// Hide the border by setting line weight to 0
textbox2.Line.Weight = 0;
// Save the result file
workbook.SaveToFile("Sample.xlsx", ExcelVersion.Version2010);
Process.Start("Sample.xlsx");
}
}
}
Imports Spire.Xls
Imports Spire.Xls.Core.Spreadsheet.Shapes
Imports System.Diagnostics
Namespace RemoveBorderlineofTextbox
Class Program
Private Shared Sub Main(args As String())
'Create a new workbook
Dim workbook As New Workbook()
workbook.Version = ExcelVersion.Version2010
' Get the first worksheet And rename it
Dim sheet As Worksheet = workbook.Worksheets(0)
sheet.Name = "Remove Borderline"
' Add a chart to the worksheet
Dim chart As Chart = sheet.Charts.Add()
' Add the first text box (with visible border)
Dim textbox1 As XlsTextBoxShape = TryCast(chart.TextBoxes.AddTextBox(50, 50, 100, 500), XlsTextBoxShape)
textbox1.Text = "The original with borderline"
'Add the second text box (border will be hidden)
Dim textbox2 As XlsTextBoxShape = TryCast(chart.TextBoxes.AddTextBox(500, 50, 100, 500), XlsTextBoxShape)
textbox2.Text = "The solution without borderline"
'Hide the border by setting line weight to 0
textbox2.Line.Weight = 0
'Save the result file
workbook.SaveToFile("Sample.xlsx", ExcelVersion.Version2010)
Process.Start("Sample.xlsx")
End Class
End Namespace
Various kinds of shapes like triangle, rectangle, ellipse, star, line and etc, can be created with Spire.Presentation. To make shapes more compatible with the entire slide, not only can we set color and choose fill style of the shape, we can also rotate shapes to a desired degree. This article is aimed to provide a simple example.
To begin with, create or open a .NET class application in Visual Studio 2005 or above versions, add Spire.Presentation.dll to your .NET project assemblies. Then, you are able create and format shapes using the sample C# code we have offered below.
Code snippets for rotate shapes on slide:
Step 1: Create an instance of Presentation class.
Presentation presentation = new Presentation();
Step 2: Add a new shape - Triangle ,to PPT slide.
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Triangle, new RectangleF(100, 100, 100, 100));
Step 3: Rotate the shape to 180 degree.
shape.Rotation = 180;
Step 4: Set the color and fill style of shape.
shape.Fill.FillType = FillFormatType.Solid; shape.Fill.SolidColor.Color = Color.BlueViolet; shape.ShapeStyle.LineColor.Color = Color.Black;
Step 5: Save and launch the file.
presentation.SaveToFile("shape.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("shape.pptx");
Effect Screenshot:

Full code:
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace RotateShape
{
class Program
{
static void Main(string[] args)
{
//create PPT document
Presentation presentation = new Presentation();
//append new shape - Triangle
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Triangle, new RectangleF(100, 100, 100, 100));
//set rotation to 180
shape.Rotation = 180;
//set the color and fill style of shape
shape.Fill.FillType = FillFormatType.Solid;
shape.Fill.SolidColor.Color = Color.BlueViolet;
shape.ShapeStyle.LineColor.Color = Color.Black;
//save the document
presentation.SaveToFile("shape.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("shape.pptx");
}
}
}
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace RotateShape
Class Program
Private Shared Sub Main(args As String())
'create PPT document
Dim presentation As New Presentation()
'append new shape - Triangle
Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Triangle, New RectangleF(100, 100, 100, 100))
'set rotation to 180
shape.Rotation = 180
'set the color and fill style of shape
shape.Fill.FillType = FillFormatType.Solid
shape.Fill.SolidColor.Color = Color.BlueViolet
shape.ShapeStyle.LineColor.Color = Color.Black
'save the document
presentation.SaveToFile("shape.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("shape.pptx")
End Sub
End Class
End Namespace