From 87a5a4ce70e3747208f595921f9114de4c470950 Mon Sep 17 00:00:00 2001 From: Brandon Desjarlais Date: Thu, 26 Sep 2024 08:58:19 -0500 Subject: [PATCH] - added get fonts for Excel files --- Office File Explorer/Helpers/Excel.cs | 24 +++++++++++++++++++++++ Office File Explorer/WinForms/FrmMain.cs | 25 ++++++++++++------------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Office File Explorer/Helpers/Excel.cs b/Office File Explorer/Helpers/Excel.cs index e380ea0..2d52880 100644 --- a/Office File Explorer/Helpers/Excel.cs +++ b/Office File Explorer/Helpers/Excel.cs @@ -410,6 +410,30 @@ public static List GetComments(string fPath) return tList; } + public static List GetFonts(string fPath) + { + List fList = new List(); + List dList = new List(); + using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(fPath, false)) + { + foreach (Font f in mySpreadsheet.WorkbookPart.WorkbookStylesPart.Stylesheet.Fonts) + { + fList.Add(f.FontName.Val); + } + } + + fList = fList.Distinct().ToList(); + + int count = 0; + foreach (string s in fList) + { + count++; + dList.Add(count + Strings.wPeriod + s); + } + + return dList; + } + public static List GetSheetInfo(string fPath) { List tList = new List(); diff --git a/Office File Explorer/WinForms/FrmMain.cs b/Office File Explorer/WinForms/FrmMain.cs index f7e9579..31d3770 100644 --- a/Office File Explorer/WinForms/FrmMain.cs +++ b/Office File Explorer/WinForms/FrmMain.cs @@ -1,13 +1,4 @@ -// Open XML SDK refs -using DocumentFormat.OpenXml; -using DocumentFormat.OpenXml.Packaging; - -// App refs -using Office_File_Explorer.Helpers; -using Office_File_Explorer.WinForms; -using Office_File_Explorer.OpenMcdf; - -// .NET refs +// .NET refs using System; using System.Collections.Generic; using System.Diagnostics; @@ -24,6 +15,15 @@ using System.Xml.Schema; using System.Xml.Linq; +// Open XML SDK refs +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; + +// App refs +using Office_File_Explorer.Helpers; +using Office_File_Explorer.WinForms; +using Office_File_Explorer.OpenMcdf; + // named refs using File = System.IO.File; using Color = System.Drawing.Color; @@ -62,7 +62,7 @@ public partial class FrmMain : Form private static string FixedFallback = string.Empty; private static string StrExtension = string.Empty; private static string StrDestFileName = string.Empty; - static StringBuilder sbNodeBuffer = new StringBuilder(); + private static StringBuilder sbNodeBuffer = new StringBuilder(); // temp files public static string tempFileReadOnly, tempFilePackageViewer; @@ -93,7 +93,7 @@ public FrmMain() { InitializeComponent(); - this.Text = Strings.oAppTitle + Strings.wMinusSign + Assembly.GetExecutingAssembly().GetCustomAttribute().Version; + Text = Strings.oAppTitle + Strings.wMinusSign + Assembly.GetExecutingAssembly().GetCustomAttribute().Version; // make sure the log file is created if (!File.Exists(Strings.fLogFilePath)) @@ -2174,6 +2174,7 @@ private void ToolStripButtonViewContents_Click(object sender, EventArgs e) sb.Append(DisplayListContents(Excel.GetDefinedNames(tempFileReadOnly), Strings.wDefinedNames)); sb.Append(DisplayListContents(Excel.GetConnections(tempFileReadOnly), Strings.wConnections)); sb.Append(DisplayListContents(Excel.GetHiddenRowCols(tempFileReadOnly), Strings.wHiddenRowCol)); + sb.Append(DisplayListContents(Excel.GetFonts(tempFileReadOnly), Strings.wFonts)); } else if (StrOfficeApp == Strings.oAppPowerPoint) {