一、.net framework 4.0环境
1.1 word篇
开发包下载地址: https://pan.baidu.com/s/13p4O0RLesD1e4nLKZ9BWPA
实验工程代码下载: https://download.csdn.net/download/u010476739/11976537
使用方法:
- 新建.net控制台程序
- 添加对aspose.words.dll的引用
- 编写代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{
Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.Write("hello word");
doc.Save(@"d:\2.docx");
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 直接运行,如下:
1.2 Excel篇
开发包下载地址: https://pan.baidu.com/s/13p4O0RLesD1e4nLKZ9BWPA
实验工程代码下载: https://download.csdn.net/download/u010476739/11977191
使用方法:
- 新建.net控制台程序
- 添加对aspose.cells.dll的引用
- 编写代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{
Aspose.Cells.Workbook wk = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet ws = wk.Worksheets[0];
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
ws.Cells.Rows[i][j].Value = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1);
}
}
wk.Save(@"d:\1.xlsx",Aspose.Cells.SaveFormat.Xlsx);
wk.Save(@"d:\1.pdf", Aspose.Cells.SaveFormat.Pdf);
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 运行如下
1.3 Pdf篇
开发包下载地址: https://pan.baidu.com/s/13p4O0RLesD1e4nLKZ9BWPA
实验工程代码下载: https://download.csdn.net/download/u010476739/11976623
使用方法:
- 新建.net控制台程序
- 添加对aspose.cells.dll的引用
- 编写代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();
page.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World!"));
doc.Save(@"d:\3.pdf");
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 运行结果如下:
1.4 ppt篇
开发包下载地址: https://pan.baidu.com/s/13p4O0RLesD1e4nLKZ9BWPA
实验工程代码下载: https://download.csdn.net/download/u010476739/11978588
使用方法:
- 新建.net控制台程序
- 添加对Aspose.Slides.dll的引用
- 编写代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{
//将一个现有的ppt转换成html
using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation("tz.pptx"))
{
pres.Save(@"tz.html", Aspose.Slides.Export.SaveFormat.Html);
}
//新建一个ppt并插入文字
using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation())
{
Aspose.Slides.IAutoShape shape1 = pres.Slides[0].Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, 100, 100, 300, 100);
shape1.UseBackgroundFill = false;
shape1.ShapeStyle.FillColor.Color = System.Drawing.Color.Transparent;
shape1.ShapeStyle.LineColor.Color= System.Drawing.Color.Transparent;
shape1.ShapeStyle.FontColor.Color = System.Drawing.Color.Black;
Aspose.Slides.TextFrameFormat format = (Aspose.Slides.TextFrameFormat)shape1.TextFrame.TextFrameFormat;
format.CenterText = Aspose.Slides.NullableBool.True;
shape1.TextFrame.Text = "这个是一个新建的文本框!\r\nHello world!";
pres.Save("1.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 运行结果如下:
二、.netstandard2.0环境
2.1 word篇
开发包下载地址: https://pan.baidu.com/s/1p2Ucr8wdv2pk5BqQQ2ChGQ
实验工程代码下载: https://download.csdn.net/download/u010476739/11976665
使用方法:
- 新建.net core控制台程序
- 添加对aspose.words.dll的引用
- 安装SkiaSharp 的nuget包
- 编写代码
using System;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.Write("hello word");
doc.Save(@"d:\2.docx");
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 直接运行,如下:
2.2 excel篇
开发包下载地址: https://pan.baidu.com/s/1XruqdcIW0HdXniTBcftJ2Q
实验工程代码下载: https://download.csdn.net/download/u010476739/11977194
使用方法:
- 新建.net core控制台程序
- 添加对aspose.cells.dll的引用
- 安装System.Drawing.Common 的nuget包
- 编写代码
using System;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
Aspose.Cells.Workbook wk = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet ws = wk.Worksheets[0];
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
ws.Cells.Rows[i][j].Value = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1);
}
}
wk.Save(@"d:\1.xlsx", Aspose.Cells.SaveFormat.Xlsx);
wk.Save(@"d:\1.pdf", Aspose.Cells.SaveFormat.Pdf);
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 直接运行,如下:
2.3 pdf篇
开发包下载地址: https://pan.baidu.com/s/1wYciX37PAFX8GjnQJ5T7tQ
实验工程代码下载: https://download.csdn.net/download/u010476739/11977198
使用方法:
- 新建.net core控制台程序
- 添加对aspose.pdf.dll的引用
- 编写代码
using System;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();
page.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World!"));
doc.Save(@"d:\3.pdf");
Console.WriteLine("ok");
Console.ReadLine();
Console.WriteLine("ok");
Console.ReadLine();
}
}
}
- 直接运行,如下:
2.4 Html篇(未实验)
开发包下载地址: https://pan.baidu.com/s/1yZXUZda2a39vk3p163QuGQ
2.5 ppt篇(Aspose.Slides,未实验)
开发包下载地址: https://pan.baidu.com/s/1bwLIJFdC4jkvpycK6ITbsg