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 8207877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:08:40+00:00 2026-06-07T09:08:40+00:00

I have a VSTO addin and I’m reading data from an Excel worksheet. It

  • 0

I have a VSTO addin and I’m reading data from an Excel worksheet.

It seems that almost all numeric data is read as a double. Is it ever possible to get an int value from Range.Value?

Here is some code to demonstrate what I mean.

Worksheet w = (Worksheet)Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets["Sheet1"];
var value = ((Range)w.Cells[1, 1]).Value;
bool isInt = value is int;
bool isDouble = value is double;

No matter which format I use in worksheet Sheet1, cell A1, isInt always comes back false.

Is there some format I should be using to get int? I thought maybe General or 0 would work, but it seems not.

  • 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-06-07T09:08:43+00:00Added an answer on June 7, 2026 at 9:08 am

    From the docs when you call var value = ((Range)w.Cells[1,1]).Value the Value type is derived from the value type from the Worksheet. So it would seem that your Excel worksheet has the values formatted as doubles, not ints. There is no “integer” formatting for Excel that will translate to C#, the best bet would be to cast the value as an integer when you read it in. The Value type comes in whatever format it was within the Excel worksheet.

    This article shows how Excel deals with double precision floating point values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that worked in the VSTO version of an Excel Addin Microsoft.Office.Tools.Excel.ListObject
I have an Excel VSTO AddIn that I moved up to Excel 2007/VS2010 last
I have a VSTO Excel workbook that functions correctly in test. I can deploy
I have an excel workbook vsto solution that needs to generate a pdf copy
I have an excel 2003 vsto workbook that I would like to make available
I have an VSTO (outlook-addin) application that uses Unity. It is deployed to a
We have a VSTO application-addin (not a document-addin) for Excel, and we want to
I'm working on an Excel Addin (VSTO) in .NET that connects to an Oracle
We have a VSTO Add in for Excel 2007. It works on all the
Hello I have the Addin for Word 2007 that is creted using VSTO. I

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.