简体   繁体   中英

How do I change data type of cells in SSRS report exported to Excel?

I have an SSRS report that is exporting data to Excel (xlsx). I have a column of data that contains dates. In the resulting XLSX file, I need the data type to be Short Date, but it comes out as General.

该图显示了Excel数据类型

I tried changing the format of my placeholder in SSRS designer (being edited with VS 2015) to a date format, but the resulting Excel file still has it as General type.

该图显示了SSRS Designer中的数字格式

The relevant XML from the RDLC is shown below.

<TablixCell>
  <CellContents>
    <Textbox Name="AdmitDate">
      <CanGrow>true</CanGrow>
      <KeepTogether>true</KeepTogether>
      <Paragraphs>
        <Paragraph>
          <TextRuns>
            <TextRun>
              <Value>=Fields!AdmitDate.Value</Value>
              <Style>
                <FontSize>8pt</FontSize>
                <Format>MM/dd/yyyy</Format>
                <Color>#4d4d4d</Color>
              </Style>
            </TextRun>
          </TextRuns>
        </Paragraph>
      </Paragraphs>
      <rd:DefaultName>AdmitDate</rd:DefaultName>
    </Textbox>
  </CellContents>
</TablixCell>

How can I get SSRS to set the data type for the cells, assuming it's possible?

I am doing a similar date field in some of my reports and they do (surprisingly) export as a Custom Date .

在此处输入图片说明

I'm thinking your field may not be recognized by SSRS as a date field. Notice that my date is 3/15/2016 in Excel's function bar while yours has the leading 0 in the month - 08/25/2008 .

Have you tried wrapping it in a CDATE function in your expression ?

=CDATE(Fields!AdmitDate.Value)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM