0

我有一个日历所有事件列表,其中包含几个字段,其中一些来自托管元数据和人员状态查找字段。当我尝试使用功能区功能将列表导出到 Excel 时,每个字段值都有一个 id 哈希标签。

这使得 excel 表非常无用和不可读。

是否有人在 SharePoint 2010 平台中尝试或遇到过此问题,以及如何将数据导出到没有 id # 标记的 Excel 中。

例如:参加者:字段包含启用人员存在的用户列表。当我将此字段值导出到 Excel 中时,每个用户都会被复制到工作表中,并带有自己独特的 # 标签,如 Doe, John;#39
或者如果它是分类管理元数据查找字段,那么导出数据将具有其独特的 #值前面的标记,如 74;#Ford

如果您能提供帮助,请告诉我。如果您有任何问题或需要进一步澄清,请随意问我。

一个建议是尝试将值复制到计算字段中,作为替换 # 标记的简单文本。但我无法根据现有查找字段的计算创建列。
其他建议是在 Excel 工作簿 Book1 中创建一个宏,可以对其进行编码以删除这些哈希标记。

我希望有一些其他更简单的方法来清理 Excel 数据表。请告诉我。谢谢,

4

3 回答 3

2

这里的答案是在 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 项目对象模型”。当然,除非您有能力对插件进行数字签名。

于 2012-07-27T19:56:15.117 回答
0

我对这个问题的解决方案是在列表中创建一个新列,根据我的情况将其命名为“OnlyValues”。我创建了一个工作流程,以便每当在列表中创建或更新项目时,我都会继续使用“Person Group”字段的值更新“OnlyValues”


Person or Group field = AssignedTo
Auxiliary field = OnlyValues

Workflow:
If Current Item:AssignedTo is not empty
 Set OnlyValues to Current Item:AssignedTo
then Stop the workflow and log Success

之后,我在列表上创建了一个视图,显示了我的其他字段和 OnlyValues 并导出到 Excel。标签现在不见了!希望这对任何人都有帮助!^^

于 2013-10-03T17:26:47.887 回答
0

我也是,用宏来清理它

Private Sub CommandButton1_Click()
'Columns to format
    Dim cols() As Variant: cols = Array("AC", "AL", "AM", "BA", "BB")
    Dim col As String


    For i = LBound(cols) To UBound(cols)
        Call FormatColumn("Sheet1", cols(i))
    Next

    MsgBox ("Formatting Lookup & Person - Group column completed.")
End Sub

Sub FormatColumn(ByVal Shet As String, ByVal col As String)
    Dim flagValueChanged As Boolean: flagValueChanged = False
    Dim strPattern1 As String: strPattern1 = "#\d+;"
    Dim strPattern2 As String: strPattern2 = "#\d+"
    Dim strPattern3 As String: strPattern3 = "#"
    Dim strReplace As String: strReplace = ""
    Dim regex As New RegExp
    With regex
        .Global = True
        .MultiLine = True
        .IgnoreCase = True
    End With

    'process for all items in the column

    rowscount = Sheets(Shet).Range("A1048576").End(xlUp).Row
    'i = 16
    For i = 2 To rowscount
        flagValueChanged = False
        currentValue = Sheets(Shet).Cells(i, col)
        'MsgBox (currentValue)

        'format Pattern1
        With regex
           .Pattern = strPattern1
        End With

        If regex.Test(currentValue) Then
           currentValue = regex.Replace(currentValue, strReplace)
           flagValueChanged = True
           'MsgBox (currentValue)
        End If

        'format Pattern2
        With regex
           .Pattern = strPattern2
        End With

        If regex.Test(currentValue) Then
           currentValue = regex.Replace(currentValue, strReplace)
           flagValueChanged = True
           'MsgBox (currentValue)
        End If

        'format Pattern3
        With regex
           .Pattern = strPattern3
        End With

        If regex.Test(currentValue) Then
           currentValue = regex.Replace(currentValue, strReplace)
           flagValueChanged = True
           'MsgBox (currentValue)
        End If

        'update formatted value
        If flagValueChanged Then
           Sheets(Shet).Cells(i, col) = currentValue
        End If

        'MsgBox (currentValue)
    Next i

End Sub
于 2016-02-04T07:55:04.657 回答