我的网页接收包含数组,对象数组和字符串的json数据。例如:
public static System.Drawing.Bitmap PadImage(System.Drawing.Bitmap originalImage)
{
if (originalImage.Height > 500)
??
if (originalImage.Width > 500)
??
Size squareSize = new Size(500, 500);
System.Drawing.Bitmap squareImage = new System.Drawing.Bitmap(squareSize.Width, squareSize.Height);
using (Graphics graphics = Graphics.FromImage(squareImage))
{
graphics.FillRectangle(System.Drawing.Brushes.White, 0, 0, squareSize.Width, squareSize.Height);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.DrawImage(originalImage, (squareSize.Width / 2) - (originalImage.Width / 2), (squareSize.Height / 2) - (originalImage.Height / 2), originalImage.Width, originalImage.Height);
}
return squareImage;
}
我可以绘制一个表格,将每个对象属性显示为对应于对象数组中对象的行的单元格。
但是,根据data.staff [key] .active的值,我希望行具有特定颜色,最后一个单元格具有按钮或接收值。 最后,我还可以绘制表格,其中表格主体中的每个元素都有一个自定义属性,其值也是从返回的json对象数组的键属性中获取的
答案 0 :(得分:0)
使用rowCallBack。
img = File.expand_path(Rails.root+'app/assets/images/scb_footer_logo.png')
sheet.add_image(:image_src => img) do |image|
image.start_at 6,6
image.end_at 6,6
end