2
我已经在c#中制作了一个程序,为了打印excel文件,他打印的很好,还打印了所有网格。但我不想看到网格。打印excel文件c#
我已经做到了这一点:
System.Windows.Forms.MessageBox.Show("Ok !", "Impression", MessageBoxButtons.OK);
//PrintDocument document = new PrintDocument();
//document.DocumentName = file;
//document.Print();
// On déclare l'application
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
// On ouvre un classeur XLS :
Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(chemin.Text,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// On ouvre la première feuille :
// la numérotation commence à 1 et pas à 0 ici
Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[1];
// Utiliser la Mise en page avec PageSetup
// Les entêtes de ligne et de colonne sont à répéter sur toutes les pages :
//ws.PageSetup.PrintTitleColumns = "$A:$B";
//ws.PageSetup.PrintTitleRows = "$1:$2";
ws.PageSetup.PrintHeadings = false;
ws.PageSetup.BlackAndWhite = false;
ws.PageSetup.PrintGridlines = true;
// Lancement de l'impression par défaut
ws.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// Afficher l’application Excel
app.Visible = false;
// Fermer l'application Excel
wb.Save();
wb.Close(false, Type.Missing, Type.Missing);
app.Quit();
// Réinitialise l'application
chemin.Text = "Imprimé !";
不要讲究的意见,我是法国人。
您是否尝试过'ws.PageSetup.PrintGridlines = FALSE;',而不是'ws.PageSetup.PrintGridlines = TRUE;'? –
Omg!谢谢你的作品。我忘了这条线...... – FlorianSL
我打算把它变成一个答案,以便你可以接受。 –