一.安装libreOffice
点击官网下载libreOffice
二.创建一个新的项目LibreOffice
创建一个新的项目,方便后面调用
添加下面代码
public class OfficeConvert
{
static string getLibreOfficePath()
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.Unix:
return "/usr/bin/soffice";
case PlatformID.Win32NT:
string binaryDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return binaryDirectory + "\\Windows\\program\\soffice.exe";
default:
throw new PlatformNotSupportedException