{
private static readonly object sync = new object()
private static Microsoft.Office.Interop.Visio.Application vso
private VisioApplication() { }
public static Microsoft.Office.Interop.Visio.Application GetInstance()
{
//单例模式,双重锁定
if (vso == null)
{
lock (sync)
{
if (vso == null)
{
vso = new Microsoft.Office.Interop.Visio.Application()
vso.Visible = false//打开应用程序就隐藏
vso.AlertResponse = (short)1//重要:转换时不用打开确认窗口,直接转换
}
}
}
return vso
}
public static void Quit()
{
if (vso != null)
{
vso.Quit()
}
GC.Collect()
}
/// <summary>
/// 将Visio文档转换成HTML格式
/// </summary>
/// <param name="VisioFilePath"></param>
public static void VisioToHtmlFile(string VisioFilePath)
{
Microsoft.Office.Interop.Visio.Application vso = GetInstance()
Microsoft.Office.Interop.Visio.Document doc = null
Microsoft.Office.Interop.Visio.SaveAsWeb.VisSaveAsWeb saveAsWeb
Microsoft.Office.Interop.Visio.SaveAsWeb.VisWebPageSettings webPageSettings
try
{
//设置输出文件路径
string strTarget = VisioFilePath.Substring(0, VisioFilePath.LastIndexOf(".")) + ".html"
//打开文档,本来想后台打开,但是无论如何都会闪一下,看大家有没有什么好的办法
doc = vso.Documents.OpenEx(VisioFilePath,
(short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRO
+ (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenMinimized
+ (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenHidden
+ (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenNoWorkspace)
//获得转换html文件用的对象
saveAsWeb = (Microsoft.Office.Interop.Visio.SaveAsWeb.VisSaveAsWeb)vso.SaveAsWebObject
//设置格式
webPageSettings = (Microsoft.Office.Interop.Visio.SaveAsWeb.VisWebPageSettings)saveAsWeb.WebPageSettings
webPageSettings.TargetPath = strTarget
webPageSettings.QuietMode = 1
webPageSettings.SilentMode = 1//安静模式,不然会显示转换进度窗口
saveAsWeb.AttachToVisioDoc(doc)//将文档添加到需要转换的列表中
saveAsWeb.CreatePages()//开始转换
}
finally
{
if (doc != null)
{
doc.Close()
}
}
}
}
1,visio code顶部的菜单栏显示和隐藏
visio code 顶部的菜单栏可以显示和隐藏
如果菜单栏不见了
点击查看=>选择外观=>切换菜单栏就可以打开,隐藏之后直接按下alt键就可以调出
2,visio常用快捷键
小键盘是fn.大键盘就把fn换成home键
如何通过手机访问本地编写的html页面
npm install http-server -g(没安装过安装一遍)
cd /Users/barry-yang/Documents/webworkspace
然后终端输入http-server
手机访问