1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
'pour abreger l'ecriture de code un alias
Imports OWC = Microsoft.Office.Interop.Owc11
Public Class frmSpreedSheet
'COMMENT AFFECTER DES VALEURS AUX CELLULES D'UN SPREADSHEET?
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'affecte quelque chose dans cellule 1,1
Me.AxSpreadsheet1.Cells(1, 1) = "Cellule 1,1"
End Sub
'JE SOUHAITE QU'UNE CELLULE REÇOIT LE CARACTÈRE "*" SI JE CLIQUE SUR CETTE CELLULE
'envoie saisie TextBox (****) vers selection
'formatte la cellulle ou les cellules selectionnes
Private Sub btnEcritSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEcritUnTexte.Click
Me.AxSpreadsheet1.Selection.Value = "****"
Me.AxSpreadsheet1.Selection.Font.Name = "Times New Roman"
Me.AxSpreadsheet1.Selection.Font.Size = 12
Me.AxSpreadsheet1.Selection.Font.Italic = True
Me.AxSpreadsheet1.Selection.Font.Bold = True
End Sub
'POUR UNE CELLULE CONTENANT UN TEXTE, COMMENT FAIRE POUR QUE LE TEXTE NE DÉPASSE PAS LA CELLULE ?
'envoie saisie d 'un TextBox vers cellule selectionne
'les caracteres de trop sont supprimes
Private Sub btnTxtVersSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTextBoxVersSelection.Click
Dim rng As OWC.Range = Nothing
Dim feuille As OWC.Worksheet = Me.AxSpreadsheet1.Worksheets(1)
rng = feuille.Cells(1, 1)
'range recoit 6 caracteres
rng.ColumnWidth = 6
TextBox2.Text = "bonjour jihad" 'cette phrase compte 13 caracteres
rng = feuille.Cells(1, 1)
rng.Value = TextBox2.Text.Substring(0, 6)
End Sub
'COMMENT FUSIONNER LES LIGNES DANS UN SPREADSHEET?
Private Sub btnFusionnerSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFusionnerSelection.Click
Dim rng As OWC.Range = Me.AxSpreadsheet1.Selection
rng.Merge()
End Sub
'recupere valeur d'une cellule selectionne dans un TextBox
Private Sub btnSelectionVersTxt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectionVersTxt.Click
Dim rng As OWC.Range = Me.AxSpreadsheet1.Selection
TextBox3.Text = rng.Value
End Sub
'efface une selection
Private Sub btnEcritSelectionStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEffaceSelection.Click
Me.AxSpreadsheet1.Selection.Clear()
End Sub
End Class |
Partager