How to export datagridview to excel in c# windows application

How to export datagridview to excel in c# windows application

Csharp Space

7 лет назад

66,453 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

KaS PeR
KaS PeR - 20.03.2023 10:53

thanks man!

Ответить
WhiteCoder
WhiteCoder - 21.01.2023 21:39

Thank You So Much....

Ответить
Tech in Life
Tech in Life - 09.11.2022 05:57

worksheet.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString(); in here it says below problem.

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Ответить
rasul valipoor
rasul valipoor - 01.06.2022 16:03

It was greatly explained, thank you, how we use border on it

Ответить
Jack Huynh
Jack Huynh - 13.01.2022 23:15

Thank you very much, it worked!

Ответить
Md. Alawal Kabir Chanchol
Md. Alawal Kabir Chanchol - 27.03.2021 11:44

Nice Tutorial. Thanks a lot.

Ответить
Mahmoud Al Hussain
Mahmoud Al Hussain - 04.02.2021 01:47

thanks for ur video ,
can u explain why you use type.missing more than one time ?

Ответить
moxmed
moxmed - 27.01.2021 11:24

how to export only checked rows if there is checkbox

Ответить
MotiVation98
MotiVation98 - 31.08.2020 13:30

My program is giving me an error on this line

Pdftable.AddCell(new Phrase(Cell.Value.ToString(),text));

Its saying Object reference not set to an instance of an object

Ответить
Thông Đinh
Thông Đinh - 30.05.2020 08:57

thank you for this video

Ответить
reuben mwangi Kibara
reuben mwangi Kibara - 25.05.2020 16:45

very great channel... would you minf helpin in exporting to pdf

Ответить
Tigran Danielyan
Tigran Danielyan - 07.05.2020 20:44

Thank you for video, how can I expoert excel from datagridview with formating.

Ответить
Radhika Gharote
Radhika Gharote - 01.05.2020 11:34

Only the the first column name is visible other columns are not visible
But the rows are visible

Ответить
Ivar Scarpin
Ivar Scarpin - 22.02.2020 22:38

Excellent video but it doesn't work for me, I got this message: Recupero della class factory COM per il componente con CLSID {00024500-0000-0000-C000-000000000046} non riuscito a causa del seguente errore: 80040154 Interfaccia non registrata. (Eccezione da HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Ответить
Yeremia Wijaya
Yeremia Wijaya - 20.02.2020 17:29

why when i close the app it didnt stop debug??

Ответить
Muhammad Restu Ramadhan
Muhammad Restu Ramadhan - 30.01.2020 07:12

my project is problem with the error code is :
An unhandled exception of type 'System.InvalidCastException'
at here > Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
can you fix this problem as soon as possible ... thanks for ur tutorial :)

Ответить
Sarim Khan
Sarim Khan - 10.12.2019 14:23

Can you tell me how to save the file directly to desktop through code?

Ответить
Viết Thọ Lê
Viết Thọ Lê - 27.11.2019 06:57

I made it. Thanks bro.😍👍

Ответить
alejandro monroy
alejandro monroy - 20.11.2019 23:08

Thank you so much , it worked :)

Ответить
انا مسلم و كفى
انا مسلم و كفى - 27.10.2019 11:23

thank you so much ,how i can check if the Sheet is empty or not

Ответить
G A
G A - 27.10.2019 10:04

The Sound is very low, could not hear you even with my volume so high, you should play it yourself and see if you can hear it, but I was able to follow because the video was clear and you moved the mouse reasonably to follow.

Ответить
Kshitij Saxena
Kshitij Saxena - 18.10.2019 14:31

How to append the excel sheet data if excel is already existing

Ответить
Dim Pap
Dim Pap - 22.07.2019 21:04

the code is not correct.

Ответить
Asiri Nadun
Asiri Nadun - 09.07.2019 14:12

It works thank you, bro!!

Ответить
Ngự Vân Bạch Hoa
Ngự Vân Bạch Hoa - 01.07.2019 05:36

I have problem in these lines:
XLSaveAsAccessMode
error : The type or namespace name 'XLSaveAsAccessMode' does not exist in the namespace 'Microsoft.Office.Interop.Excel' (are you missing an assembly reference?)
CAN YOU HELP ME!

Ответить
Shahryzal
Shahryzal - 15.06.2019 18:56

Thank you so much for this tutorial
(^-^)

Ответить
Simone Esposito
Simone Esposito - 13.04.2019 09:55

Ottimo good

Ответить
KING Merlin
KING Merlin - 28.01.2019 11:21

Hi iwanted to ask, is this also compatible with WPF gridview in C#

Ответить
md. nurul huda
md. nurul huda - 07.01.2019 21:40

Do I can show a preview instead of direct save dialogue????

Ответить
Cybel Maloon
Cybel Maloon - 14.12.2018 12:40

Sir, I have this error could you lend me a hand for this error "System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index' "

Ответить
Shehzad Bhatti
Shehzad Bhatti - 17.10.2018 12:32

Hey Bro, I'm having this issue "System.NullReferenceException: 'Object reference not defined for an instance of an object.
System.Windows.Forms.DataGridViewCell.Value.get retorned null." in this line "worksheet.Cells[i+2,j+1] = produtoDataGridView.Rows[i].Cells[j].Value.ToString();" Could you help me pls?

Ответить
Paulo Herculano
Paulo Herculano - 02.08.2018 05:09

Hey Bro, I'm having this issue "System.NullReferenceException: 'Object reference not defined for an instance of an object.
System.Windows.Forms.DataGridViewCell.Value.get retorned null." in this line "worksheet.Cells[i+2,j+1] = produtoDataGridView.Rows[i].Cells[j].Value.ToString();" Could you help me pls?

Ответить
Ganesh Gavali
Ganesh Gavali - 01.08.2018 12:29

Exception thrown: 'System.ArgumentOutOfRangeException' in mscorlib.dll

Ответить
LUISA FERNANDA PINEDA DE LA OSSA
LUISA FERNANDA PINEDA DE LA OSSA - 31.07.2018 01:53

hola tengo un ERROR en esta linea de codigo HELP
sheet.Cells [i + 2, j + 1] = dataGridView1.Rows [i] .Cells [j] .Value.ToString ();"

Ответить
Suraj Shinde
Suraj Shinde - 23.07.2018 06:44

Thanks

Ответить
Rishabh Narayan
Rishabh Narayan - 25.06.2018 19:26

System.BadImageFormatException: 'Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 800700c1 is not a valid Win32 application. (Exception from HRESULT: 0x800700C1).'
I'm getting this error please help

Ответить
richard melvin garcia
richard melvin garcia - 07.06.2018 06:54

saves only 4 rows?

Ответить
John Krain
John Krain - 01.06.2018 04:25

if you try to overwrite the name on same folder, it will show rewrite warning twice. :(

Ответить
Neyleen Caraballo
Neyleen Caraballo - 05.05.2018 18:54

Thank you so much!!! But I need help with the next: " code : " worksheet = workbook.Sheets["Sheet1"];" present the next error"Additional information: El índice no es válido. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))".

Ответить
Philip Harrison A
Philip Harrison A - 17.03.2018 13:04

worksheet = workbook.Sheets["Sheet1"];
worksheet = workbook.ActiveSheet;

error in these lines

Error 1 Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Excel._Worksheet'. An explicit conversion exists (are you missing a cast?) C:\Users\Dhivya\Desktop\FaceRecProOV\MakeRegistered.cs 105 25 MultiFaceRec

Ответить
Marlon Dumdumaya
Marlon Dumdumaya - 22.02.2018 08:04

hello, Im having a problem int the codes, "Object reference not set to an instance of an object." in "sheet.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();"

Ответить
alligationYT
alligationYT - 31.01.2018 16:57

Hello, i have a problem. Where can i find the Microsoft Excel 15.0 Object Library. I'm using C# 2010 Express. My system has error. It says, Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) and the other one is Check the error code properly of the exception to determine the HRESULT returned by the COM object. Please help me. Thank you!

Ответить
The Webjunky
The Webjunky - 09.01.2018 01:19

sound lvl is not very loud

Ответить
Oops SpiderMan - ychirong - Thầy SpiderMan
Oops SpiderMan - ychirong - Thầy SpiderMan - 19.11.2017 13:24

Thank you so much!! But you have video :"How to import excel to datagridview in c# windows application" ?

Ответить
Noppawin SRIKULCHAYANAN
Noppawin SRIKULCHAYANAN - 10.11.2017 10:46

Thank you very much!!

Ответить
Sheetal Kedar
Sheetal Kedar - 07.09.2017 12:39

i want to save image to excel sheet using c# . any solution????? plz help ...!!

Ответить