Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6053161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:00:32+00:00 2026-05-23T08:00:32+00:00

When generating an Excel XML workbook with ASP.NET i’m appending 3 cells in a

  • 0

When generating an Excel XML workbook with ASP.NET i’m appending 3 cells in a row like:

sb.Append(String.Format(
"<Cell><Data ss:Type=\"DateTime\">{1}</Data></Cell>{0}",
Environment.NewLine, 
item.DateAvailable.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK")
)); // newlines added for readability;

item.DateAvailable is a C# DateTime that has to end in Excel as An cell-DateTime.

so

value from debug in VS2010 in asssembly:

 2011-08-15T01:16:06.8470000    

value in excel:

 40761,2299142361

after manual conversion of the cell formatting:

 6-08-11 5:31

However, when converting it outputs in excel as a number, and the cell formatting is set to custom. When I manually change the cell formatting back to DateTime the correct??? date is shown in the correct format. But of course, the business would not accept such a raw data they have to convert themselves 😉

Perhaps I am using the wrong StringFormat?

What is the correct format to write a DateTime in this case and output it in Excel in the correct DateTime Format?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:00:32+00:00Added an answer on May 23, 2026 at 8:00 am

    Yes, you are using a “wrong” string format, i.e. a format that Excel does not automatically recognize (or parse appropriately) as a date. Drop the T. Also, the date-time format in Excel rounds at least to milliseconds, if not to integer seconds, so you might as well drop some of those decimal places.

    This should work:

    item.DateAvailable.ToString("yyyy-MM-dd HH:mm:ss.ffff")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET page where I'm generating an Excel spreadsheet and sending that
In my ASP.NET MVC application I am generating excel reports, I have a template
In my ASP.Net application I'm generating a Excel file using MsExcel Object Libby (Com-InterOp)
I need to design a small project for generating excel reports in .NET, which
I am generating an Excel file through MATLAB and I have empty cells in
I have an ASP.NET web service which does some heavy lifting, like say,some file
I'm generating large Excel files, in xlsx format. The files contain 100+ thousand rows,
Has anyone used a Java based library for generating excel documents? Preferably support for
I have long HTTP request ( generating large Excel file - about 60K records
Generating normal columnar data in excel file is quite easy but does any one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.