Auteur de questions
WPF, Exportation en pdf d'une feuille de calcul Excel génère un message d'erreur

Discussion générale
-
Bonjour j'ai un code qui exporte une feuille de calcul Excel au format pdf dans un dossier.
Malheureusement il génère une MessageBox avec une erreur :
voici mon code :
private void TraitementCommBtn_Click(object sender, RoutedEventArgs e) { TraitementCommBtn.Cursor = System.Windows.Input.Cursors.Wait; var _with3 = oSheetCommande; ColisageFullPath = System.IO.Path.Combine(DossierDocument, ColisagePath + DateTxtBlock.Text + "-" + ClientCB.Text.ToString() + "-" + ProduitCB.Text.ToString()+"_"+ NumCommandeTB.Text.ToString()); ColisageTempFullPath= System.IO.Path.Combine(DossierDocument, ColisagePathTemp + DateTxtBlock.Text + "-" + ClientCB.Text.ToString() + "-" + ProduitCB.Text.ToString()+"_"+ NumCommandeTB.Text.ToString()); FichierNumCommandeTxtFullPath = System.IO.Path.Combine(DossierDocument, FichierNumCommandeTxtPath); var mess = System.Windows.MessageBox.Show("Souhaitez-vous envoyer ce bon de commande au service commercial immédiatement ?\nVous pourrez l'envoyer ultérieurement en utilisant le bouton @ Commandes", "Envois de commande",MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Cancel); switch (mess) { case MessageBoxResult.No: oSheetCommande.Select(); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageTempFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].PrintOutEx(); break; case MessageBoxResult.Yes: oSheetCommande.Select(); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].PrintOutEx(); SendCommandeToCommercialMail(); break; } using (StreamWriter sw1 = new StreamWriter(FichierNumCommandeTxtFullPath)) { sw1.Write(NumCommandeTB.Text.ToString()); } TraitementCommBtn.Cursor = System.Windows.Input.Cursors.Hand; TraitementCommBtn.IsEnabled = false; NewCommandeBtn.IsEnabled = true; System.Windows.Clipboard.Clear(); //XlApp.Visible = false; }
JF Collombet ® CreateSpecificCulture
- Type modifié Nina ZaekovaMicrosoft contingent staff, Moderator jeudi 10 août 2017 14:05
Toutes les réponses
-
A noter que se problème ne se pose pas sur mon PC qui exécute Visual Studio, la le debug du code s'effectue sans problème. C'est sur l'ordinateur utilisateur équipé de Windows 7 pro que survient le problème.
Je viens donc d'insérer un bloc Try au niveau de l'exportation pdf pour voir si cela me retourne des infos plus précises.
JF Collombet ® CreateSpecificCulture
-
Bonjour Jean-François,
Est-ce que la feuille est en mode aperçu au lieu d’être en mode normal? Je vous propose de consulter ce lien:
Excel 2010 Save As PDF Adobe Reader X ErrorsCordialement,
Dimitar- Modifié Dimitar DenkovMicrosoft contingent staff, Moderator jeudi 20 juillet 2017 06:07
-
-
Bonjour, je me permet de reposter ce thread auquel je n'ai pas trouvé de réponse malgré les recherche sur le net :
Bonjour j'ai un code qui exporte une feuille de calcul Excel au format pdf dans un dossier.
Malheureusement il génère une MessageBox avec une erreur :private void TraitementCommBtn_Click(object sender, RoutedEventArgs e) { TraitementCommBtn.Cursor = System.Windows.Input.Cursors.Wait; var _with3 = oSheetCommande; ColisageFullPath = System.IO.Path.Combine(DossierDocument, ColisagePath + DateTxtBlock.Text + "-" + ClientCB.Text.ToString() + "-" + ProduitCB.Text.ToString()+"_"+ NumCommandeTB.Text.ToString()); ColisageTempFullPath= System.IO.Path.Combine(DossierDocument, ColisagePathTemp + DateTxtBlock.Text + "-" + ClientCB.Text.ToString() + "-" + ProduitCB.Text.ToString()+"_"+ NumCommandeTB.Text.ToString()); FichierNumCommandeTxtFullPath = System.IO.Path.Combine(DossierDocument, FichierNumCommandeTxtPath); var mess = System.Windows.MessageBox.Show("Souhaitez-vous envoyer ce bon de commande au service commercial immédiatement ?\nVous pourrez l'envoyer ultérieurement en utilisant le bouton @ Commandes", "Envois de commande",MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Cancel); switch (mess) { case MessageBoxResult.No: oSheetCommande.Select(); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageTempFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].PrintOutEx(); break; case MessageBoxResult.Yes: oSheetCommande.Select(); _with3.Range["A1:S52"].ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, ColisageFullPath, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, 1, 10, false); _with3.Range["A1:S52"].PrintOutEx(); SendCommandeToCommercialMail(); break; } using (StreamWriter sw1 = new StreamWriter(FichierNumCommandeTxtFullPath)) { sw1.Write(NumCommandeTB.Text.ToString()); } TraitementCommBtn.Cursor = System.Windows.Input.Cursors.Hand; TraitementCommBtn.IsEnabled = false; NewCommandeBtn.IsEnabled = true; System.Windows.Clipboard.Clear(); //XlApp.Visible = false; }
JF Collombet ® CreateSpecificCulture
- Fusionné Nina ZaekovaMicrosoft contingent staff, Moderator vendredi 28 juillet 2017 13:44 thread en double
-