Я использовал вышеупомянутый метод (пользовательская функция Anton PL / SQL pivot ()), и он выполнил задание! Поскольку я не профессиональный разработчик Oracle, это простые шаги, которые я сделал:
1) Загрузите пакет zip, чтобы найти там pivotFun.sql. 2) Запустите один раз pivotFun.sql, чтобы создать новую функцию. 3) Используйте эту функцию в обычном SQL.
Просто будьте осторожны с именами динамических колонок. В моей среде я обнаружил, что имя столбца ограничено 30 символами и не может содержать в себе одну цитату. Итак, мой запрос теперь выглядит примерно так:
SELECT
*
FROM
table(
pivot('
SELECT DISTINCT
P.proj_id,
REPLACE(substr(T.UDF_TYPE_LABEL, 1, 30), '''''''','','') as Attribute,
CASE
WHEN V.udf_text is null and V.udf_date is null and V.udf_number is NOT null THEN to_char(V.udf_number)
WHEN V.udf_text is null and V.udf_date is NOT null and V.udf_number is null THEN to_char(V.udf_date)
WHEN V.udf_text is NOT null and V.udf_date is null and V.udf_number is null THEN V.udf_text
ELSE NULL END
AS VALUE
FROM
project P
LEFT JOIN UDFVALUE V ON P.proj_id = V.proj_id
LEFT JOIN UDFTYPE T ON V.UDF_TYPE_ID = T.UDF_TYPE_ID
WHERE
P.delete_session_id IS NULL AND
T.TABLE_NAME = ''PROJECT''
')
)
Хорошо работает с записью до 1 м.
Вы можете построить логику на следующем коде, который вставляет форму линии полной ширины в середину каждой ячейки в таблице.
Document doc = new Document("E:\\temp\\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
foreach (Table table in doc.FirstSection.Body.Tables)
{
foreach (Row row in table.Rows)
{
foreach (Cell cell in row.Cells)
{
enumerator.Current = collector.GetEntity(cell.FirstParagraph);
while (enumerator.Type != LayoutEntityType.Cell)
{
enumerator.MoveParent();
}
double top = enumerator.Rectangle.Top + (enumerator.Rectangle.Height / 2);
double left = enumerator.Rectangle.Left;
double width = enumerator.Rectangle.Width;
builder.MoveTo(table.NextSibling);
Shape line = builder.InsertShape(ShapeType.Line, width, 0);
line.Top = top;
line.Left = left;
line.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
line.RelativeVerticalPosition = RelativeVerticalPosition.Page;
line.BehindText = true;
line.WrapType = WrapType.None;
line.StrokeColor = Color.Blue;
line.Stroke.LineStyle = ShapeLineStyle.Single;
line.StrokeWeight = 1;
}
}
}
doc.Save("E:\\temp\\19.1.docx");
Надеюсь, это поможет. Я работаю с Aspose в качестве разработчика Evangelist.