No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

HtmlDgv.cs

Description du code

HtmlDgv.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.IO;
  3. using System.Windows.Forms;
  4. using be.gaudry.model.enums;
  5. using be.gaudry.view.dialogs;
  6.  
  7. namespace be.gaudry.view.utils.dgvFactory
  8. {
  9. public class HtmlDgv : AbstractDgv
  10. {
  11. #region declarations and constructors
  12. private SaveFileDialog saveFileDialog;
  13. public HtmlDgv()
  14. {
  15. saveFileDialog = new SaveFileDialog();
  16. saveFileDialog.CheckPathExists = true;
  17. saveFileDialog.CheckFileExists = false;
  18. saveFileDialog.AddExtension = true;
  19. saveFileDialog.CreatePrompt = true;
  20. saveFileDialog.DefaultExt = ".html";
  21. saveFileDialog.Filter = "Page Web (*.html;*.htm)|*.html;*.htm|Tous les fichiers (*.*)|*.*";
  22. saveFileDialog.FilterIndex = 1;
  23. }
  24. #endregion
  25.  
  26. public override void print(DataGridView dgv)
  27. {
  28. this.dgv = dgv;
  29. //setLayoutOptions(outputTitle);
  30.  
  31. DialogResult dr;
  32. if (dialogOwner != null)
  33. {
  34. dr = saveFileDialog.ShowDialog(dialogOwner);
  35. }
  36. else
  37. {
  38. dr = saveFileDialog.ShowDialog();
  39. }
  40. if (dr == DialogResult.OK)
  41. {
  42. print(saveFileDialog.FileName);
  43. }
  44. }
  45.  
  46. private void print(string destinationFile)
  47. {
  48. bool writed = false;
  49. StreamWriter writer = new StreamWriter(destinationFile, false);
  50. try
  51. {
  52. writer.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">");
  53. //iso-8859-1
  54. writer.WriteLine("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><title>{0}</title>", new string[] { PrintTitle });
  55. writer.Write("<style>th, td {border-bottom:solid 1px");
  56. writer.Write(" orange;border-right:solid 1px orange;}");
  57. writer.Write(" table {font:normal 12px verdana}");
  58. writer.WriteLine("</style></head><body>");
  59. writer.WriteLine("<h1>{0}</h1>", new string[] { PrintTitle });
  60.  
  61. string dateStr = "";
  62. if (DisplayDate)
  63. {
  64. dateStr = string.Format(
  65. "\nLe {0} à {1}\n",
  66. DateTime.Now.ToLongDateString(),
  67. DateTime.Now.ToShortTimeString()
  68. );
  69. }
  70. if (DisplayDate && textPlacement == TEXT_POSITION.Header)
  71. {
  72. writer.WriteLine("<p>{0}</p>", new string[] { dateStr });
  73. }
  74.  
  75. writer.WriteLine("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"90%\" >");
  76.  
  77. writer.Write("<tr bgcolor='#FF9933'>");
  78. foreach (DataGridViewColumn dgvCol in SelectedColumns)
  79. {
  80. writer.Write("<th align='center'>{0}</th>", new string[] { dgvCol.HeaderText });
  81. }
  82. writer.WriteLine("</tr>");
  83.  
  84. foreach (DataGridViewRow dgvRow in dgv.Rows)
  85. {
  86. writer.WriteLine("<tr>");
  87. foreach (DataGridViewCell dgvCell in dgvRow.Cells)
  88. {
  89. if (!SelectedColumns.Contains(dgvCell.OwningColumn))
  90. continue;
  91. writer.Write("<td>{0} </td>", new string[] { dgvCell.EditedFormattedValue.ToString() });
  92. }
  93. writer.WriteLine("</tr>");
  94. }
  95. writer.WriteLine("</table></div>");
  96.  
  97. if (DisplayDate && textPlacement == TEXT_POSITION.Footer)
  98. {
  99. writer.WriteLine("<p>{0}</p>", new string[] { dateStr });
  100. }
  101.  
  102. writer.WriteLine("</body></html>");
  103. writed = true;
  104. /*MessageBox.Show(
  105.   this.dialogOwner,
  106.   "Le fichier est sauvé.",
  107.   "Sauvegarde",
  108.   MessageBoxButtons.OK,
  109.   MessageBoxIcon.Information,
  110.   MessageBoxDefaultButton.Button1
  111.   );*/
  112. }
  113. catch (Exception e)
  114. {
  115. ExceptionDialog.ShowDialog(e,this.dialogOwner);
  116. }
  117. finally
  118. {
  119. writer.Close();
  120. }
  121. if (writed)
  122. {
  123. CustomOpenResultFileDialog.Show(
  124. this.dialogOwner,
  125. destinationFile,
  126. "Le fichier est sauvé.\nVous pouvez sélectionner une action à effectuer.",
  127. "Sauvegarde",
  128. MessageBoxIcon.Information
  129. );
  130. }
  131. }
  132. }
  133. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/utils/dgvFactory/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1719954994 02/07/2024 23:16:34
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/utils/dgvFactory/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csHtmlDgv.cs5.03 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csExcelDgv.cs18.77 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csXMLDgv.cs3.02 Ko31/10/2018 18:33:23-refusé-
Afficher le fichier .cs|.csCSVDgv.cs5.02 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csPrintDgv.cs18.02 Ko31/10/2018 18:33:23-refusé-
Afficher le fichier .cs|.csIDgv.cs271 octets31/10/2018 18:33:23-refusé-
Afficher le fichier .cs|.csTextDgv.cs4.02 Ko31/10/2018 18:33:23-refusé-
Afficher le fichier .cs|.csAbstractDgv.cs3.46 Ko31/10/2018 18:33:22-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-broldev-source-rf-view/utils/dgvFactory/HtmlDgv.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.