导出到Excel时包含托管元数据的列表有奇怪的字符?

时间:2012-07-24 18:20:22

标签: sharepoint-2010 metadata export-to-excel taxonomy

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

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

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

例如: 参与者:字段包含启用了人员状态的用户列表。 当我将此字段值导出到Excel中时,每个用户都会被复制到具有自己唯一#标签的工作表中,如在Doe,John;#39中 或者,如果它是分类法管理元数据查找字段,则导出数据将在值前面具有其唯一的#标记,如74中所示; #Ford

如果您能提供帮助,请与我们联系。如果您有任何问题或需要进一步澄清,请自由地问我。

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

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

3 个答案:

答案 0 :(得分: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项目对象模型”。除非您当然能够对插件进行数字签名。

答案 1 :(得分:0)

我对此问题的解决方案是在列表中创建一个新列,根据您的意愿将其命名为“OnlyValues”。我创建了一个工作流,这样无论何时在列表上创建或更新项目,我都会使用“人员组”字段的值更新“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。 Hashtags现在已经不见了!希望这有助于任何人! ^^

答案 2 :(得分: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