Beispiel #1
0
        private void BT_Imprimir_Click(object sender, EventArgs e)
        {
            // Choose whether to write header. Use EnableWithoutHeaderText instead to omit header.
            DGV_Análisis.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
            // Select all the cells
            DGV_Análisis.SelectAll();
            // Copy selected cells to DataObject
            DataObject dataObject = DGV_Análisis.GetClipboardContent();

            // Get the text of the DataObject, and serialize it to a file
            if (!Directory.Exists(pathDestino))
            {
                Directory.CreateDirectory(pathDestino);
            }
            string nombre = IO.GetUniqueFilename(pathDestino, plantilla.nombre + "_" + DateTime.Today.ToString("dd-MM-yyyy"));

            string aux = dataObject.GetText(TextDataFormat.CommaSeparatedValue);

            aux = aux.Replace('\n', ' ');
            aux = aux.Replace("\r", "\r\n");

            File.WriteAllText(nombre, aux);
            DGV_Análisis.ClearSelection();
            MessageBox.Show("Se ha guardado la exploración con el nombre: " + Path.GetFileName(nombre));
        }
Beispiel #2
0
        private void BT_Exportar_Click(object sender, EventArgs e)
        {
            // Choose whether to write header. Use EnableWithoutHeaderText instead to omit header.
            DGV_Análisis.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
            // Select all the cells
            DGV_Análisis.SelectAll();
            // Copy selected cells to DataObject
            DataObject dataObject = DGV_Análisis.GetClipboardContent();

            // Get the text of the DataObject, and serialize it to a file
            File.WriteAllText(plantilla.nombre + "_" + DateTime.Today.ToShortDateString() + ".txt", dataObject.GetText(TextDataFormat.CommaSeparatedValue));
        }