这里的答案是在 Excel 中创建一个清理宏,然后所有电子表格都可以通过存储在 XLSTART 本地计算机目录中的 .xlam 插件访问该宏。
这个 VBA 代码不是很漂亮,但它就像一个魅力:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Remove_unneeded()
' Remove_unneeded Macro
' Removes extraneous hash setup from SharePoint exported workbook
Dim Again As Integer
Dim Again1 As Range
On Error GoTo Nope
Set Again1 = Cells.Find(What:="?;#", LookAt:=xlPart)
If Again1 Is Nothing Then
Set Again1 = Cells.Find(What:=";#?", LookAt:=xlPart)
If Again1 Is Nothing Then
GoTo Nope
End If
End If
Range("A1").Select
Again = 1
Do While Again < 5
Set Again1 = Cells.Find(What:="0;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="0;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="0;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="1;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="1;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="1;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="2;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="2;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="2;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="3;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="3;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="3;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="4;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="4;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="4;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="5;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="5;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="5;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="6;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="6;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="6;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="7;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="7;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="7;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="8;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="8;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="8;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="9;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="9;#", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="9;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#0", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#0", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#0", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#1", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#1", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#1", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#2", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#2", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#2", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#3", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#3", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#3", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#4", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#4", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#4", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#5", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#5", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#5", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#6", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#6", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#6", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#7", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#7", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#7", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#8", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#8", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#8", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#9", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#9", Replacement:=";#", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#9", LookAt:=xlPart)
Loop
Again = Again + 1
Loop
Set Again1 = Cells.Find(What:="#;#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="#;#", Replacement:=" | ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="#;#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:=";#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:=";#", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:=";#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="#;", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="#;", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="#;", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="#", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="#", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="#", LookAt:=xlPart)
Loop
Set Again1 = Cells.Find(What:="; |", LookAt:=xlPart)
Do While Not Again1 Is Nothing
Cells.Replace What:="; |", Replacement:=" |", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Set Again1 = Cells.Find(What:="; |", LookAt:=xlPart)
Loop
Range("A1").Select
MsgBox "Extraneous hash data has been deleted."
Exit Sub
Nope:
MsgBox "This is not the proper spreadsheet setup to run this macro."
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我还在 xlam 中创建了一个带有 iRibbon 控件的附加宏,以通过 Excel 中自定义功能区上的按钮访问此宏,然后编辑 xlam UI xml 以适应它。但这只是装腔作势,因为一旦您准备好使用宏,您就可以按照自己喜欢的方式设置 UI。
您必须在“信任中心”、“宏选项”的“Excel 选项”中打开“信任 VBA 项目对象模型”。当然,除非您有能力对插件进行数字签名。