I have long series of numbers (ex. 10000203005595000) and as I pass the value to the excel, i have a (ex. 10000E^+10) value, what should be the code in C# to manipulate the Format Cells/Number/Category/Fraction. To have a specific value I have. Please Help me, Thanks :-)
this is my program:`
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using Microsoft.Office.Interop.Excel;
using System.Text.RegularExpressions;
namespace BIS
{
public partial class labDB : Form
{
System.Data.DataTable data;
public labDB()
{
InitializeComponent();
}
//this is my report generator using Excel
private void genReport_Click(object sender, EventArgs e)
{
saveFileDialog1.InitialDirectory = "C:";
saveFileDialog1.Title = "Save as Excel File";
saveFileDialog1.FileName = "Laboratory Department Inventory Report";
saveFileDialog1.Filter = "Excel Files(2003)|*.xls|Excel Files(2007)|*.xlsx|Excel Files(2010)|*.xlsx|Excel Files(2013)|*.xlsx";
if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
{
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Application.Workbooks.Add(Type.Missing);
ExcelApp.Columns.ColumnWidth = 25;
for (int i = 1; i < dataGridViewLAB.Columns.Count + 1; i++)
{
ExcelApp.Cells[1, i] = dataGridViewLAB.Columns[i - 1].HeaderText;
}
for (int i = 0; i < dataGridViewLAB.Rows.Count; i++)
{
for (int j = 0; j < dataGridViewLAB.Columns.Count; j++)
{
ExcelApp.Cells[i + 2, j + 1] = dataGridViewLAB.Rows[i].Cells[j].Value.ToString();
}
}
ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog1.FileName.ToString());
ExcelApp.ActiveWorkbook.Saved = true;
ExcelApp.Quit();
}
}
}
}