Copy an Excel sheet to new sheet including formatting - C# -


I need to create a method that is capable of copying Excel sheet and then paste it on a new Excel sheet. There is only one workbook, but it is also necessary to copy the formatting.

I have received many codes, but they do not copy all formatting, just below the code written below the text:

  // Open Excel file Microsoft. Office.Interop.Excel.Application excel = null; Excel = new Microsoft.Office.Interop.Excel.Application (); Microsoft.Office.Interop.Excel.Workbook Workbook = excel.Workbooks.Open (File, Type. Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type. Type missing, type missing, type missing, type missing, type missing, type missing); Microsoft.Office.Interop.Excel.Sheets Sheet = Workbook. Worksheets; Microsoft.Office.Interop.Excel.Worksheet Sheet = (Microsoft.Office.Interop.Excel.Worksheet) Sheets.Get_ITOM (1); Microsoft.Office.Interop.Excel.Worksheet sheet2 = (Microsoft.Office.Interop.Excel.Worksheet) Sheets.Gate_item (2); // Copy the source sheet Default Default = Type missing; Sheet = (Worksheet) Workbook. Sheets [1]; Sheet.UsedRange.Copy (defaultArg); // Paste to Destination Sheet Sheet 2. 2. Range used. Paste paste type, axle paste values, expedited special operation, axle paste special operation, non, first, falls); Workbook.Save (); Common.closeExcel (excel, workbook);  

If anyone has any suggestions, please let me know.

Thanks,

This will make a real copy of a sheet of a new sheet Will be named as, whose name has been changed by default:

  dim x = 2 numtimes = 1 to x for sheet 1 copy _ after: = sheet 1 next  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -