Reputation: 84
I'll try say what i want: I create a word doc, and add a table, fine, but the border of table are transparent and i cant work with it, i need to write at doc to save as PDF.
I have a nice class that control word, but with table i lost my mind i didnt solve the problem.
I using winform with .net 3.5
// atributos - atributes
public static object missing = System.Reflection.Missing.Value; // Valores defauls que não precisa alterar
public static Word.Application w_app; // aplicação do word
public static Word.Document w_doc; // documento do word
// metodos - methods
public void criar_novo_arquivo_word() // create a new file word doc
{
Word.Application app = new Word.Application();
w_app = app;
w_doc = app.Documents.Add(missing, missing, missing, missing);
w_app.Visible = false;
}
public void visualizar_word(bool opcao) // set visible
{
w_app.Visible = opcao;
}
public void inserir_tabela(int numero_de_linhas, int numero_de_colunas) // insert table, here live my problema
{
Word.Range range = w_doc.Range(ref missing, ref missing);
range.Tables.Add(range, numero_de_linhas, numero_de_colunas);
}
Upvotes: 0
Views: 2563
Reputation: 2746
Try this:
public void inserir_tabela(int numero_de_linhas, int numero_de_colunas) // insert table, here live my problema
{
Word.Range range = w_doc.Range(ref missing, ref missing);
Word.Table myTable = range.Tables.Add(range, numero_de_linhas, numero_de_colunas);
myTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
myTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
}
Upvotes: 5