ssrs数据源CSV半冒号分隔,给出长列名称

时间:2018-05-31 08:06:12

标签: sql sql-server reporting-services

我有一个自动但以分号生成csv的工具;但是当我在SSRS中运行查询时,它只为报告中的所有字段提供一列。当我用逗号更改分号时,它运行良好 我想修改或更改SSRS中的设置以提供正确的格式。我运行查询,例如csv有sample1; sample2; sample3 ;;;; A; B; C; ,输出给出sample1; sample2; sample3 ;;;; A; B; C;

我尝试以这种方式更改reportingservices.config但不能正常工作

  

enter image description here

 <Extension Name="Semicolon" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering">
                <OverrideNames>

    <Name Language="en-US">CSV (semicolon delimited)</Name>
                 <Name Language="en-EN">CSV (semicolon delimited)</Name>


                </OverrideNames>
                <Configuration>
                    <DeviceInfo>
             <FileExtension>csv</FileExtension>
                        <FieldDelimiter>;</FieldDelimiter>
<SuppressLineBreaks>True</SuppressLineBreaks>
                    </DeviceInfo>
                </Configuration>
            </Extension>   

我想要这种输出。

sample1 |  sample2 | sample3
     a          b         c

有关如何在SSRS中执行此操作的任何想法。

1 个答案:

答案 0 :(得分:0)

我决定只编写一个批处理文件,以便在.exe应用程序生成csv后立即替换分号。要替换的示例也在此链接中:Batch script to find and replace a string in text file without creating an extra output file for storing the modified file

@echo off
setlocal enabledelayedexpansion




::  rem   editing and replacing  a text file without redirecting the output to file 

@echo off 
    setlocal enableextensions disabledelayedexpansion

    set "search=%;"
    set "replace=%,"

    set "textFile=try2.csv"

    for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
        set "line=%%i"
        setlocal enabledelayedexpansion
        >>"%textFile%" echo(!line:%search%=%replace%!
        endlocal
    )
pause