2011-01-20 5 views
1

私はHTML to OpenXMLコンバータを使用していますが、gridview HTMLコードはstringbuilderに割り当てられています。これを使用して、そのHTMLをOpenXMLに変換しますが、単語になると以下の問題が見つかります。openxmlのテーブルのイメージとランダムな行の色に関する問題?

  1. Iはgrainsboro色でテーブルの行の背景を充填する必要はなく、テキストのみの背景が充填され、完全に細胞ではありません。

  2. 私は、ヘッダーのイメージを右に揃えたいと思っていました。

これは、私は、プロパティハイライトテキストの色があるとOpenXMLの中で考えてC#で

A***building image code plz tell me how to align the image to right*** 
d=DocumentFormat.OpenXml.Drawing; 
int emuWidth = (int)(pixelWidth * EMU_PER_PIXEL); 
int emuHeight = (int)(pixelHeight * EMU_PER_PIXEL); 
Drawing drawing = new Drawing(); 
d.Wordprocessing.Inline inline = new d.Wordprocessing.Inline { DistanceFromTop = 130, DistanceFromBottom = 430, DistanceFromLeft = 260, DistanceFromRight = 330 }; 
d.Wordprocessing.Anchor anchor = new d.Wordprocessing.Anchor { DistanceFromTop = 0, DistanceFromBottom = 0, DistanceFromLeft = 0, DistanceFromRight = 0 }; 
d.Wordprocessing.SimplePosition simplePos = new d.Wordprocessing.SimplePosition { X = 0, Y = 0 }; 
d.Wordprocessing.Extent extent = new d.Wordprocessing.Extent { Cx = emuWidth, Cy = emuHeight }; 
d.Wordprocessing.DocProperties docPr = new d.Wordprocessing.DocProperties { Id = 1, Name = imageName }; 
d.Wordprocessing.HorizontalPosition h = new d.Wordprocessing.HorizontalPosition(new d.Wordprocessing.HorizontalAlignment("right")); 

d.Graphic graphic = new d.Graphic(); 
// We don’t have to hard code a URI anywhere else in the document but if we don’t do it here 
// we end up with a corrupt document. 
d.GraphicData graphicData = new d.GraphicData { Uri = GRAPHIC_DATA_URI }; 
d.Pictures.Picture pic = new d.Pictures.Picture(); 
d.Pictures.NonVisualPictureProperties nvPicPr = new d.Pictures.NonVisualPictureProperties(); 
d.Pictures.NonVisualDrawingProperties cNvPr = new d.Pictures.NonVisualDrawingProperties { Id = 2, Name = imageName }; 
d.Pictures.NonVisualPictureDrawingProperties cNvPicPr = new d.Pictures.NonVisualPictureDrawingProperties(); 
d.Pictures.BlipFill blipFill = new d.Pictures.BlipFill(); 
d.Blip blip = new d.Blip { Embed = imageRelationshipID }; 
d.Stretch stretch = new d.Stretch(); 
d.FillRectangle fillRect = new d.FillRectangle(); 
d.Pictures.ShapeProperties spPr = new d.Pictures.ShapeProperties(); 
d.Transform2D xfrm = new d.Transform2D(); 
d.Offset off = new d.Offset { X = 0, Y = 0 }; 
d.Extents ext = new d.Extents { Cx = emuWidth, Cy = emuHeight }; 
d.PresetGeometry prstGeom = new d.PresetGeometry { Preset = d.ShapeTypeValues.Rectangle }; 
d.AdjustValueList avLst = new d.AdjustValueList(); 
xfrm.Append(off); 
xfrm.Append(ext); 
prstGeom.Append(avLst); 
stretch.Append(fillRect); 
spPr.Append(xfrm); 
spPr.Append(prstGeom); 
blipFill.Append(blip); 
blipFill.Append(stretch); 
nvPicPr.Append(cNvPr); 
nvPicPr.Append(cNvPicPr); 
pic.Append(nvPicPr); 
pic.Append(blipFill); 
pic.Append(spPr); 
graphicData.Append(pic); 
graphic.Append(graphicData); 
inline.Append(extent); 
inline.Append(docPr); 
inline.Append(graphic); 
//anchor.Append(extent); 
//anchor.Append(docPr); 
//anchor.Append(h); 
//anchor.Append(graphic); 

drawing.Append(inline); 

return drawing; 

を行ってasp.netアプリケーションです。どのようにC#コードでそれを取得できますか?

+1

この

は私が使用しているコードです。また、あなたは2つの質問があるので、あなたはそれらを分離し、2つの別個の質問を開く必要があります。 –

答えて

0

実際には、図面の配置を直接設定しません。たとえば段落に配置し、プロパティの配置を設定します。あなたは他の人が代わりに「PLZ C#コードで私を与える」というのがそれを修正する場所を指している可能性がありますように、あなたのコードを共有したい場合があり

public void AddImageParagraph(Drawing element, JustificationValues alignment = JustificationValues.Left) 
{ 

    Paragraph paragraph = new Paragraph(); 
    ParagraphProperties paragraphProperties = new ParagraphProperties(); 
    Justification justification = new Justification() 
    { 
     Val = alignment 
    }; 
    paragraphProperties.Append(justification); 
    Run run = new Run(element); 
    paragraph.Append(run); 
    paragraph.Append(paragraphProperties); 
    mBody.Append(paragraph); 
} 
関連する問題