Skip to content

Commit

Permalink
- added get fonts for Excel files
Browse files Browse the repository at this point in the history
  • Loading branch information
desjarlais committed Sep 26, 2024
1 parent bf4ee3b commit 87a5a4c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
24 changes: 24 additions & 0 deletions Office File Explorer/Helpers/Excel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,30 @@ public static List<string> GetComments(string fPath)
return tList;
}

public static List<string> GetFonts(string fPath)
{
List<string> fList = new List<string>();
List<string> dList = new List<string>();
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<string> GetSheetInfo(string fPath)
{
List<string> tList = new List<string>();
Expand Down
25 changes: 13 additions & 12 deletions Office File Explorer/WinForms/FrmMain.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -93,7 +93,7 @@ public FrmMain()
{
InitializeComponent();

this.Text = Strings.oAppTitle + Strings.wMinusSign + Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
Text = Strings.oAppTitle + Strings.wMinusSign + Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version;

// make sure the log file is created
if (!File.Exists(Strings.fLogFilePath))
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 87a5a4c

Please sign in to comment.