C#Aspose.Wordsではワード変換および指定された複数の画像に戻ります

 

公共 ResultResponse < 文字列 []> PrintStudyRecords([FromBody]スタディーインフォメーション情報)
        { 
            ResultResponse < 文字列 []> RET = 新しい ResultResponse < 文字列 []> ();
            もし(info.ProjectId <= 0 
            { 
                ret.Flag = リターンRET; 
            } 
            VARのプロジェクト= ProjectContract.GetFilterProject(P => p.Id == info.ProjectId).FirstOrDefault();
            もし(プロジェクト== nullの
            { 
                ret.Flag = リターンRET; 
            } 
            VAR trainTarget = TrainTargetContract.GetFilterTrainTargets(T => t.Id == project.TrainTargetId).FirstOrDefault();
            VAR studyRecords = StudyRecordsContract.GetList(S => s.ProjectId == info.ProjectId && s.IsFinish &&!s.IsDelete).ToList(); 
            ドキュメントのドキュメント。
            使用してVARストリーム= System.IO.File.OpenRead(HttpContext.Current.Server.MapPath(" /コンテンツ/学时记录.docxの" )))
            { 
                ドキュメント = 文書(ストリーム)。
            } 
            doc.Range.Replace(ストリング .Format(" $ {0} $ "" ")、LoginUser.Name、)。
            doc.Range.Replace(ストリング .Format(" $ {0} $ "" PersonalId ")、LoginUser.PersonalId、)。
            doc.Range.Replace(ストリング .Format(" $ {0} $ "" 性別")、文字列 .IsNullOrWhiteSpace(LoginUser.Sex)?"":LoginUser.Sex、); 
            doc.Range.Replace(ストリング .Format(" $ {0} $ "" PHONENUM ")、ストリング .IsNullOrWhiteSpace(LoginUser.Tel)?"":LoginUser.Tel、)。
            doc.Range.Replace(文字列 .Format(" $ {0} $ "" 会社")、文字列 .IsNullOrWhiteSpace(プロジェクト。"":project.Company、); 
            doc.Range.Replace(文字列 .Format(" $ {0} $ "" TrainTargetName ")、trainTarget =!ヌル trainTarget.TrainName:?"" ); 
            doc.Range.Replace(ストリング .Format(" $ {0} $ "" AllHours ")、studyRecords.Count()のToString()。)。
表tableRecord
=(テーブル)doc.GetChild(NodeType.Table、2)。 もし(tableRecord == NULL { VARの OP = 新しいImageSaveOptions(SaveFormat.Jpeg)。 op.PrettyFormat = ; ret.Result = 新しい 文字列[doc.PageCount]。 VARのページ= 0 ;ページ<doc.PageCount、ページ++ { op.PageIndex =ページ; 使用VARの MS = 新規のMemoryStream()) { doc.Save(MS、OP)。 ret.Result [ページ] = " データ:画像/ JPEG、BASE64、" + Convert.ToBase64String(ms.GetBuffer())。 } } ret.Flag = リターンRET; } 場合(studyRecords.Count()> 1 { ためint型のI =0 ; I studyRecords.Count < - 1。 ; Iは++ { // クローン指定された行の 行= clonedRow(行)tableRecord.LastRow.Clone(真の); // 指定された場所にクローニング行に挿入 tableRecord.AppendChild(clonedRow); } } VaRの rowIndexに= 0 ; ZhuJian.Entity.TrainManage.StudyRecord studyRecord = NULL ; のためのint型 I = 0 ; IはstudyRecords.Countを<Iは++ { studyRecord = studyRecords [I]。 rowIndexに = I + 1 VaRの行= tableRecord.Rows [rowIndexプロパティ]。 VAR CELL0 = row.Cells [ 0 ]。 段落PG0 = 新しいパラグラフ(DOC); pg0.AppendChild(新しいファイル名を指定して実行(DOC、rowIndexに+ "" )); cell0.RemoveAllChildren(); cell0.AppendChild(PG0)。 VAR CELL1 = row.Cells [ 1 ]。 段落PG1 = 新しいです段落(DOC)。 pg1.AppendChild(新しいファイル名を指定して実行(DOC、studyRecord.StartTime.ToString(" YYYY / MM / DD ")+ " - "?+(studyRecord.EndTime.HasValue studyRecord.EndTime.Value.ToString(" YYYY / MM / DD "):"" ))); cell1.RemoveAllChildren(); cell1.AppendChild(PG1)。 VAR CELL2 = row.Cells [ 2 ]。 段落PG2 = 新しいパラグラフ(DOC); pg2.AppendChild(新しいファイル名を指定して実行(DOC、studyRecord.ResourceName)); cell2.RemoveAllChildren(); cell2.AppendChild(PG2)。 VAR CELL3 = row.Cells [ 3 ]。 段落PG3 = 新しいパラグラフ(DOC); pg3.AppendChild(新しいファイル名を指定して実行(DOC、studyRecord.IsFinish?" 1 "" 0 " )); cell3.RemoveAllChildren(); cell3.AppendChild(PG3)。 } VARのオプション= 新しいImageSaveOptions(SaveFormat.Jpeg)。 option.PrettyFormat = ; ret.Result = 新しい 文字列[doc.PageCount]。 VARのページ= 0 ;ページ<doc.PageCount、ページ++ { option.PageIndex = ページ。 使用VARの MS = 新規のMemoryStream()) { doc.Save(MS、オプション)。 ret.Result [ページ] = " データ:画像/ JPEG、BASE64、" + Convert.ToBase64String(ms.GetBuffer())。 } } ret.Flag = ; 戻る権利を。 }

 

 

おすすめ

転載: www.cnblogs.com/xiaonangua/p/11304504.html