資源簡介
c#操作Libreoffice組件,對應一些常見的文件格式進行轉換,其中包含Word,html,excel,pdf,image,等等,有相關Demo,可以參考實現

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?unoidl.com.sun.star.beans;
using?unoidl.com.sun.star.lang;
using?unoidl.com.sun.star.frame;
using?System.IO;
namespace?LibreOfficeConvert
{
????public?partial?class?HtmlAndWord?:?Form
????{
????????//必須安裝Libre?Office軟件引用dll類庫LibreOffice功能強大可以多種文件之間的相互轉換
????????//具體轉換的文件類型可以參考去官方論壇查詢類型文件本demo應用于word與html之間的轉換
????????//二次開發幫助文檔在bin目錄下還有個簡單篩選器文檔
????????public?HtmlAndWord()
????????{
????????????InitializeComponent();
????????}
????????public?string?GetDate()
????????{
????????????return?string.Format(“{0}{1}{2}{3}{4}{5}“?System.DateTime.Now.Year?System.DateTime.Now.Month?System.DateTime.Now.Day?System.DateTime.Now.Hour?System.DateTime.Now.Minute?System.DateTime.Now.Second);
????????}
????????private?void?LiuLang_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?a?=?new?OpenFileDialog();
????????????a.ShowDialog();
????????????if?(a.FileName.Trim().Length?>?0)
????????????{
????????????????if?(a.FileName.Split(‘.‘).Length?>?1)
????????????????{
????????????????????string?type?=?a.FileName.ToLowerInvariant().Substring(a.FileName.LastIndexOf(“.“)?+?1);
????????????????????if?(type?==?“docx“?||?type?==?“doc“?||?type?==?“html“?||?type?==?“htm“)
????????????????????{
????????????????????????FileNameText.Text?=?a.FileName;
????????????????????}
????????????????????else
????????????????????{
????????????????????????MessageBox.Show(“文件不是可識別類型“?“提示“?MessageBoxButtons.OK);
????????????????????????return;
????????????????????}
????????????????}
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“請選擇文件“?“提示“?MessageBoxButtons.OK);
????????????????return;
????????????}
????????}
????????//文件類型實體
????????private?PropertyValue[]?GetPropertyValues(int?index?string?name1?string?value1?string?name2?string?value2)
????????{
????????????PropertyValue[]?propertyValue?=?new?PropertyValue[index];
????????????if?(!string.IsNullOrEmpty(name1)?&&?!string.IsNullOrEmpty(value1))
????????????{
????????????????PropertyValue?aProperty?=?new?PropertyValue();
????????????????aProperty.Name?=?name1;
????????????????aProperty.Value?=?new?uno.Any(value1);
????????????????propertyValue[0]?=?aProperty;
????????????}
????????????if?(!string.IsNullOrEmpty(name2)?&&?!string.IsNullOrEmpty(value2))
????????????{
????????????????PropertyValue?aProperty?=?new?PropertyValue();
????????????????aProperty.Name?=?name2;
????????????????aProperty.Value?=?new?uno.Any(value2);
????????????????propertyValue[1]?=?aProperty;
????????????}
????????????return?propertyValue;
????????}
????????private?static?string?PathConverter(string?file)
????????{
????????????try
????????????{
????????????????file?=?file.Replace(@“\“?“/“);
????????????????return?“file:///“?+?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????2467815??2011-02-14?22:02??LibreOfficeConvert\bin\AndrewMacro.pdf
?????文件??????11264??2014-12-03?21:31??LibreOfficeConvert\bin\cli_ba
?????文件?????143360??2014-12-04?14:56??LibreOfficeConvert\bin\cli_cppuhelper.dll
?????文件????1140224??2014-12-04?08:54??LibreOfficeConvert\bin\cli_oootypes.dll
?????文件???????8192??2014-12-04?09:10??LibreOfficeConvert\bin\cli_ure.dll
?????文件?????112640??2014-12-04?08:45??LibreOfficeConvert\bin\cli_uretypes.dll
?????文件??????11264??2014-12-03?21:31??LibreOfficeConvert\bin\Debug\cli_ba
?????文件?????143360??2014-12-04?14:56??LibreOfficeConvert\bin\Debug\cli_cppuhelper.dll
?????文件????1140224??2014-12-04?08:54??LibreOfficeConvert\bin\Debug\cli_oootypes.dll
?????文件???????8192??2014-12-04?09:10??LibreOfficeConvert\bin\Debug\cli_ure.dll
?????文件?????112640??2014-12-04?08:45??LibreOfficeConvert\bin\Debug\cli_uretypes.dll
?????文件??????13824??2015-01-23?15:43??LibreOfficeConvert\bin\Debug\LibreOfficeConvert.exe
?????文件??????26112??2015-01-23?15:43??LibreOfficeConvert\bin\Debug\LibreOfficeConvert.pdb
?????文件??????11600??2015-01-23?09:09??LibreOfficeConvert\bin\Debug\LibreOfficeConvert.vshost.exe
?????文件????????490??2010-03-17?22:39??LibreOfficeConvert\bin\Debug\LibreOfficeConvert.vshost.exe.manifest
?????文件???????6764??2015-01-23?11:22??LibreOfficeConvert\bin\篩選器.txt
?????文件???????8953??2015-01-23?15:02??LibreOfficeConvert\HtmlAndWord.cs
?????文件???????6132??2015-01-23?14:31??LibreOfficeConvert\HtmlAndWord.Designer.cs
?????文件???????5817??2015-01-23?14:29??LibreOfficeConvert\HtmlAndWord.resx
?????文件???????4256??2015-01-23?15:03??LibreOfficeConvert\LibreOfficeConvert.csproj
?????文件???????7127??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????544??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\GenerateResource.read.1.tlog
?????文件???????1230??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\GenerateResource.write.1.tlog
?????文件???????2106??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\LibreOfficeConvert.csproj.FileListAbsolute.txt
?????文件??????13824??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\LibreOfficeConvert.exe
?????文件????????180??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\LibreOfficeConvert.HtmlAndWord.resources
?????文件??????26112??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\LibreOfficeConvert.pdb
?????文件????????180??2015-01-23?15:43??LibreOfficeConvert\obj\x86\Debug\LibreOfficeConvert.Properties.Resources.resources
?????文件????????505??2015-01-23?14:31??LibreOfficeConvert\Program.cs
?????文件???????1392??2015-01-23?09:09??LibreOfficeConvert\Properties\AssemblyInfo.cs
............此處省略16個文件信息
- 上一篇:社區管理系統asp
- 下一篇:基于Qt開發的IM即時通訊軟件
評論
共有 條評論